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 | function _typeof(obj) {
|
27 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
28 | _typeof = function (obj) {
|
29 | return typeof obj;
|
30 | };
|
31 | } else {
|
32 | _typeof = function (obj) {
|
33 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
34 | };
|
35 | }
|
36 |
|
37 | return _typeof(obj);
|
38 | }
|
39 |
|
40 | function _defineProperty(obj, key, value) {
|
41 | if (key in obj) {
|
42 | Object.defineProperty(obj, key, {
|
43 | value: value,
|
44 | enumerable: true,
|
45 | configurable: true,
|
46 | writable: true
|
47 | });
|
48 | } else {
|
49 | obj[key] = value;
|
50 | }
|
51 |
|
52 | return obj;
|
53 | }
|
54 |
|
55 | function ownKeys(object, enumerableOnly) {
|
56 | var keys = Object.keys(object);
|
57 |
|
58 | if (Object.getOwnPropertySymbols) {
|
59 | keys.push.apply(keys, Object.getOwnPropertySymbols(object));
|
60 | }
|
61 |
|
62 | if (enumerableOnly) keys = keys.filter(function (sym) {
|
63 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
64 | });
|
65 | return keys;
|
66 | }
|
67 |
|
68 | function _objectSpread2(target) {
|
69 | for (var i = 1; i < arguments.length; i++) {
|
70 | var source = arguments[i] != null ? arguments[i] : {};
|
71 |
|
72 | if (i % 2) {
|
73 | ownKeys(source, true).forEach(function (key) {
|
74 | _defineProperty(target, key, source[key]);
|
75 | });
|
76 | } else if (Object.getOwnPropertyDescriptors) {
|
77 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
78 | } else {
|
79 | ownKeys(source).forEach(function (key) {
|
80 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
81 | });
|
82 | }
|
83 | }
|
84 |
|
85 | return target;
|
86 | }
|
87 |
|
88 | function _toConsumableArray(arr) {
|
89 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
90 | }
|
91 |
|
92 | function _arrayWithoutHoles(arr) {
|
93 | if (Array.isArray(arr)) {
|
94 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
95 |
|
96 | return arr2;
|
97 | }
|
98 | }
|
99 |
|
100 | function _iterableToArray(iter) {
|
101 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
102 | }
|
103 |
|
104 | function _nonIterableSpread() {
|
105 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
106 | }
|
107 |
|
108 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
109 |
|
110 | function commonjsRequire() {
|
111 | throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
112 | }
|
113 |
|
114 | function createCommonjsModule(fn, module) {
|
115 | return module = {
|
116 | exports: {}
|
117 | }, fn(module, module.exports), module.exports;
|
118 | }
|
119 |
|
120 | var moment = createCommonjsModule(function (module, exports) {
|
121 | (function (global, factory) {
|
122 | module.exports = factory();
|
123 | })(commonjsGlobal, function () {
|
124 | var hookCallback;
|
125 |
|
126 | function hooks() {
|
127 | return hookCallback.apply(null, arguments);
|
128 | }
|
129 |
|
130 |
|
131 |
|
132 | function setHookCallback(callback) {
|
133 | hookCallback = callback;
|
134 | }
|
135 |
|
136 | function isArray(input) {
|
137 | return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
138 | }
|
139 |
|
140 | function isObject(input) {
|
141 |
|
142 |
|
143 | return input != null && Object.prototype.toString.call(input) === '[object Object]';
|
144 | }
|
145 |
|
146 | function isObjectEmpty(obj) {
|
147 | if (Object.getOwnPropertyNames) {
|
148 | return Object.getOwnPropertyNames(obj).length === 0;
|
149 | } else {
|
150 | var k;
|
151 |
|
152 | for (k in obj) {
|
153 | if (obj.hasOwnProperty(k)) {
|
154 | return false;
|
155 | }
|
156 | }
|
157 |
|
158 | return true;
|
159 | }
|
160 | }
|
161 |
|
162 | function isUndefined(input) {
|
163 | return input === void 0;
|
164 | }
|
165 |
|
166 | function isNumber(input) {
|
167 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
168 | }
|
169 |
|
170 | function isDate(input) {
|
171 | return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
172 | }
|
173 |
|
174 | function map(arr, fn) {
|
175 | var res = [],
|
176 | i;
|
177 |
|
178 | for (i = 0; i < arr.length; ++i) {
|
179 | res.push(fn(arr[i], i));
|
180 | }
|
181 |
|
182 | return res;
|
183 | }
|
184 |
|
185 | function hasOwnProp(a, b) {
|
186 | return Object.prototype.hasOwnProperty.call(a, b);
|
187 | }
|
188 |
|
189 | function extend(a, b) {
|
190 | for (var i in b) {
|
191 | if (hasOwnProp(b, i)) {
|
192 | a[i] = b[i];
|
193 | }
|
194 | }
|
195 |
|
196 | if (hasOwnProp(b, 'toString')) {
|
197 | a.toString = b.toString;
|
198 | }
|
199 |
|
200 | if (hasOwnProp(b, 'valueOf')) {
|
201 | a.valueOf = b.valueOf;
|
202 | }
|
203 |
|
204 | return a;
|
205 | }
|
206 |
|
207 | function createUTC(input, format, locale, strict) {
|
208 | return createLocalOrUTC(input, format, locale, strict, true).utc();
|
209 | }
|
210 |
|
211 | function defaultParsingFlags() {
|
212 |
|
213 | return {
|
214 | empty: false,
|
215 | unusedTokens: [],
|
216 | unusedInput: [],
|
217 | overflow: -2,
|
218 | charsLeftOver: 0,
|
219 | nullInput: false,
|
220 | invalidMonth: null,
|
221 | invalidFormat: false,
|
222 | userInvalidated: false,
|
223 | iso: false,
|
224 | parsedDateParts: [],
|
225 | meridiem: null,
|
226 | rfc2822: false,
|
227 | weekdayMismatch: false
|
228 | };
|
229 | }
|
230 |
|
231 | function getParsingFlags(m) {
|
232 | if (m._pf == null) {
|
233 | m._pf = defaultParsingFlags();
|
234 | }
|
235 |
|
236 | return m._pf;
|
237 | }
|
238 |
|
239 | var some;
|
240 |
|
241 | if (Array.prototype.some) {
|
242 | some = Array.prototype.some;
|
243 | } else {
|
244 | some = function (fun) {
|
245 | var t = Object(this);
|
246 | var len = t.length >>> 0;
|
247 |
|
248 | for (var i = 0; i < len; i++) {
|
249 | if (i in t && fun.call(this, t[i], i, t)) {
|
250 | return true;
|
251 | }
|
252 | }
|
253 |
|
254 | return false;
|
255 | };
|
256 | }
|
257 |
|
258 | function isValid(m) {
|
259 | if (m._isValid == null) {
|
260 | var flags = getParsingFlags(m);
|
261 | var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
262 | return i != null;
|
263 | });
|
264 | var isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || flags.meridiem && parsedParts);
|
265 |
|
266 | if (m._strict) {
|
267 | isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === undefined;
|
268 | }
|
269 |
|
270 | if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
271 | m._isValid = isNowValid;
|
272 | } else {
|
273 | return isNowValid;
|
274 | }
|
275 | }
|
276 |
|
277 | return m._isValid;
|
278 | }
|
279 |
|
280 | function createInvalid(flags) {
|
281 | var m = createUTC(NaN);
|
282 |
|
283 | if (flags != null) {
|
284 | extend(getParsingFlags(m), flags);
|
285 | } else {
|
286 | getParsingFlags(m).userInvalidated = true;
|
287 | }
|
288 |
|
289 | return m;
|
290 | }
|
291 |
|
292 |
|
293 |
|
294 | var momentProperties = hooks.momentProperties = [];
|
295 |
|
296 | function copyConfig(to, from) {
|
297 | var i, prop, val;
|
298 |
|
299 | if (!isUndefined(from._isAMomentObject)) {
|
300 | to._isAMomentObject = from._isAMomentObject;
|
301 | }
|
302 |
|
303 | if (!isUndefined(from._i)) {
|
304 | to._i = from._i;
|
305 | }
|
306 |
|
307 | if (!isUndefined(from._f)) {
|
308 | to._f = from._f;
|
309 | }
|
310 |
|
311 | if (!isUndefined(from._l)) {
|
312 | to._l = from._l;
|
313 | }
|
314 |
|
315 | if (!isUndefined(from._strict)) {
|
316 | to._strict = from._strict;
|
317 | }
|
318 |
|
319 | if (!isUndefined(from._tzm)) {
|
320 | to._tzm = from._tzm;
|
321 | }
|
322 |
|
323 | if (!isUndefined(from._isUTC)) {
|
324 | to._isUTC = from._isUTC;
|
325 | }
|
326 |
|
327 | if (!isUndefined(from._offset)) {
|
328 | to._offset = from._offset;
|
329 | }
|
330 |
|
331 | if (!isUndefined(from._pf)) {
|
332 | to._pf = getParsingFlags(from);
|
333 | }
|
334 |
|
335 | if (!isUndefined(from._locale)) {
|
336 | to._locale = from._locale;
|
337 | }
|
338 |
|
339 | if (momentProperties.length > 0) {
|
340 | for (i = 0; i < momentProperties.length; i++) {
|
341 | prop = momentProperties[i];
|
342 | val = from[prop];
|
343 |
|
344 | if (!isUndefined(val)) {
|
345 | to[prop] = val;
|
346 | }
|
347 | }
|
348 | }
|
349 |
|
350 | return to;
|
351 | }
|
352 |
|
353 | var updateInProgress = false;
|
354 |
|
355 | function Moment(config) {
|
356 | copyConfig(this, config);
|
357 | this._d = new Date(config._d != null ? config._d.getTime() : NaN);
|
358 |
|
359 | if (!this.isValid()) {
|
360 | this._d = new Date(NaN);
|
361 | }
|
362 |
|
363 |
|
364 |
|
365 | if (updateInProgress === false) {
|
366 | updateInProgress = true;
|
367 | hooks.updateOffset(this);
|
368 | updateInProgress = false;
|
369 | }
|
370 | }
|
371 |
|
372 | function isMoment(obj) {
|
373 | return obj instanceof Moment || obj != null && obj._isAMomentObject != null;
|
374 | }
|
375 |
|
376 | function absFloor(number) {
|
377 | if (number < 0) {
|
378 |
|
379 | return Math.ceil(number) || 0;
|
380 | } else {
|
381 | return Math.floor(number);
|
382 | }
|
383 | }
|
384 |
|
385 | function toInt(argumentForCoercion) {
|
386 | var coercedNumber = +argumentForCoercion,
|
387 | value = 0;
|
388 |
|
389 | if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
390 | value = absFloor(coercedNumber);
|
391 | }
|
392 |
|
393 | return value;
|
394 | }
|
395 |
|
396 |
|
397 | function compareArrays(array1, array2, dontConvert) {
|
398 | var len = Math.min(array1.length, array2.length),
|
399 | lengthDiff = Math.abs(array1.length - array2.length),
|
400 | diffs = 0,
|
401 | i;
|
402 |
|
403 | for (i = 0; i < len; i++) {
|
404 | if (dontConvert && array1[i] !== array2[i] || !dontConvert && toInt(array1[i]) !== toInt(array2[i])) {
|
405 | diffs++;
|
406 | }
|
407 | }
|
408 |
|
409 | return diffs + lengthDiff;
|
410 | }
|
411 |
|
412 | function warn(msg) {
|
413 | if (hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
|
414 | console.warn('Deprecation warning: ' + msg);
|
415 | }
|
416 | }
|
417 |
|
418 | function deprecate(msg, fn) {
|
419 | var firstTime = true;
|
420 | return extend(function () {
|
421 | if (hooks.deprecationHandler != null) {
|
422 | hooks.deprecationHandler(null, msg);
|
423 | }
|
424 |
|
425 | if (firstTime) {
|
426 | var args = [];
|
427 | var arg;
|
428 |
|
429 | for (var i = 0; i < arguments.length; i++) {
|
430 | arg = '';
|
431 |
|
432 | if (typeof arguments[i] === 'object') {
|
433 | arg += '\n[' + i + '] ';
|
434 |
|
435 | for (var key in arguments[0]) {
|
436 | arg += key + ': ' + arguments[0][key] + ', ';
|
437 | }
|
438 |
|
439 | arg = arg.slice(0, -2);
|
440 | } else {
|
441 | arg = arguments[i];
|
442 | }
|
443 |
|
444 | args.push(arg);
|
445 | }
|
446 |
|
447 | warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + new Error().stack);
|
448 | firstTime = false;
|
449 | }
|
450 |
|
451 | return fn.apply(this, arguments);
|
452 | }, fn);
|
453 | }
|
454 |
|
455 | var deprecations = {};
|
456 |
|
457 | function deprecateSimple(name, msg) {
|
458 | if (hooks.deprecationHandler != null) {
|
459 | hooks.deprecationHandler(name, msg);
|
460 | }
|
461 |
|
462 | if (!deprecations[name]) {
|
463 | warn(msg);
|
464 | deprecations[name] = true;
|
465 | }
|
466 | }
|
467 |
|
468 | hooks.suppressDeprecationWarnings = false;
|
469 | hooks.deprecationHandler = null;
|
470 |
|
471 | function isFunction(input) {
|
472 | return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
473 | }
|
474 |
|
475 | function set(config) {
|
476 | var prop, i;
|
477 |
|
478 | for (i in config) {
|
479 | prop = config[i];
|
480 |
|
481 | if (isFunction(prop)) {
|
482 | this[i] = prop;
|
483 | } else {
|
484 | this['_' + i] = prop;
|
485 | }
|
486 | }
|
487 |
|
488 | this._config = config;
|
489 |
|
490 |
|
491 |
|
492 | this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source);
|
493 | }
|
494 |
|
495 | function mergeConfigs(parentConfig, childConfig) {
|
496 | var res = extend({}, parentConfig),
|
497 | prop;
|
498 |
|
499 | for (prop in childConfig) {
|
500 | if (hasOwnProp(childConfig, prop)) {
|
501 | if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
|
502 | res[prop] = {};
|
503 | extend(res[prop], parentConfig[prop]);
|
504 | extend(res[prop], childConfig[prop]);
|
505 | } else if (childConfig[prop] != null) {
|
506 | res[prop] = childConfig[prop];
|
507 | } else {
|
508 | delete res[prop];
|
509 | }
|
510 | }
|
511 | }
|
512 |
|
513 | for (prop in parentConfig) {
|
514 | if (hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop])) {
|
515 |
|
516 | res[prop] = extend({}, res[prop]);
|
517 | }
|
518 | }
|
519 |
|
520 | return res;
|
521 | }
|
522 |
|
523 | function Locale(config) {
|
524 | if (config != null) {
|
525 | this.set(config);
|
526 | }
|
527 | }
|
528 |
|
529 | var keys;
|
530 |
|
531 | if (Object.keys) {
|
532 | keys = Object.keys;
|
533 | } else {
|
534 | keys = function (obj) {
|
535 | var i,
|
536 | res = [];
|
537 |
|
538 | for (i in obj) {
|
539 | if (hasOwnProp(obj, i)) {
|
540 | res.push(i);
|
541 | }
|
542 | }
|
543 |
|
544 | return res;
|
545 | };
|
546 | }
|
547 |
|
548 | var defaultCalendar = {
|
549 | sameDay: '[Today at] LT',
|
550 | nextDay: '[Tomorrow at] LT',
|
551 | nextWeek: 'dddd [at] LT',
|
552 | lastDay: '[Yesterday at] LT',
|
553 | lastWeek: '[Last] dddd [at] LT',
|
554 | sameElse: 'L'
|
555 | };
|
556 |
|
557 | function calendar(key, mom, now) {
|
558 | var output = this._calendar[key] || this._calendar['sameElse'];
|
559 | return isFunction(output) ? output.call(mom, now) : output;
|
560 | }
|
561 |
|
562 | var defaultLongDateFormat = {
|
563 | LTS: 'h:mm:ss A',
|
564 | LT: 'h:mm A',
|
565 | L: 'MM/DD/YYYY',
|
566 | LL: 'MMMM D, YYYY',
|
567 | LLL: 'MMMM D, YYYY h:mm A',
|
568 | LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
569 | };
|
570 |
|
571 | function longDateFormat(key) {
|
572 | var format = this._longDateFormat[key],
|
573 | formatUpper = this._longDateFormat[key.toUpperCase()];
|
574 |
|
575 | if (format || !formatUpper) {
|
576 | return format;
|
577 | }
|
578 |
|
579 | this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
580 | return val.slice(1);
|
581 | });
|
582 | return this._longDateFormat[key];
|
583 | }
|
584 |
|
585 | var defaultInvalidDate = 'Invalid date';
|
586 |
|
587 | function invalidDate() {
|
588 | return this._invalidDate;
|
589 | }
|
590 |
|
591 | var defaultOrdinal = '%d';
|
592 | var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
|
593 |
|
594 | function ordinal(number) {
|
595 | return this._ordinal.replace('%d', number);
|
596 | }
|
597 |
|
598 | var defaultRelativeTime = {
|
599 | future: 'in %s',
|
600 | past: '%s ago',
|
601 | s: 'a few seconds',
|
602 | ss: '%d seconds',
|
603 | m: 'a minute',
|
604 | mm: '%d minutes',
|
605 | h: 'an hour',
|
606 | hh: '%d hours',
|
607 | d: 'a day',
|
608 | dd: '%d days',
|
609 | M: 'a month',
|
610 | MM: '%d months',
|
611 | y: 'a year',
|
612 | yy: '%d years'
|
613 | };
|
614 |
|
615 | function relativeTime(number, withoutSuffix, string, isFuture) {
|
616 | var output = this._relativeTime[string];
|
617 | return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number);
|
618 | }
|
619 |
|
620 | function pastFuture(diff, output) {
|
621 | var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
622 | return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
623 | }
|
624 |
|
625 | var aliases = {};
|
626 |
|
627 | function addUnitAlias(unit, shorthand) {
|
628 | var lowerCase = unit.toLowerCase();
|
629 | aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
|
630 | }
|
631 |
|
632 | function normalizeUnits(units) {
|
633 | return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
|
634 | }
|
635 |
|
636 | function normalizeObjectUnits(inputObject) {
|
637 | var normalizedInput = {},
|
638 | normalizedProp,
|
639 | prop;
|
640 |
|
641 | for (prop in inputObject) {
|
642 | if (hasOwnProp(inputObject, prop)) {
|
643 | normalizedProp = normalizeUnits(prop);
|
644 |
|
645 | if (normalizedProp) {
|
646 | normalizedInput[normalizedProp] = inputObject[prop];
|
647 | }
|
648 | }
|
649 | }
|
650 |
|
651 | return normalizedInput;
|
652 | }
|
653 |
|
654 | var priorities = {};
|
655 |
|
656 | function addUnitPriority(unit, priority) {
|
657 | priorities[unit] = priority;
|
658 | }
|
659 |
|
660 | function getPrioritizedUnits(unitsObj) {
|
661 | var units = [];
|
662 |
|
663 | for (var u in unitsObj) {
|
664 | units.push({
|
665 | unit: u,
|
666 | priority: priorities[u]
|
667 | });
|
668 | }
|
669 |
|
670 | units.sort(function (a, b) {
|
671 | return a.priority - b.priority;
|
672 | });
|
673 | return units;
|
674 | }
|
675 |
|
676 | function zeroFill(number, targetLength, forceSign) {
|
677 | var absNumber = '' + Math.abs(number),
|
678 | zerosToFill = targetLength - absNumber.length,
|
679 | sign = number >= 0;
|
680 | return (sign ? forceSign ? '+' : '' : '-') + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
681 | }
|
682 |
|
683 | var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
|
684 | var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
685 | var formatFunctions = {};
|
686 | var formatTokenFunctions = {};
|
687 |
|
688 |
|
689 |
|
690 |
|
691 | function addFormatToken(token, padded, ordinal, callback) {
|
692 | var func = callback;
|
693 |
|
694 | if (typeof callback === 'string') {
|
695 | func = function () {
|
696 | return this[callback]();
|
697 | };
|
698 | }
|
699 |
|
700 | if (token) {
|
701 | formatTokenFunctions[token] = func;
|
702 | }
|
703 |
|
704 | if (padded) {
|
705 | formatTokenFunctions[padded[0]] = function () {
|
706 | return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
|
707 | };
|
708 | }
|
709 |
|
710 | if (ordinal) {
|
711 | formatTokenFunctions[ordinal] = function () {
|
712 | return this.localeData().ordinal(func.apply(this, arguments), token);
|
713 | };
|
714 | }
|
715 | }
|
716 |
|
717 | function removeFormattingTokens(input) {
|
718 | if (input.match(/\[[\s\S]/)) {
|
719 | return input.replace(/^\[|\]$/g, '');
|
720 | }
|
721 |
|
722 | return input.replace(/\\/g, '');
|
723 | }
|
724 |
|
725 | function makeFormatFunction(format) {
|
726 | var array = format.match(formattingTokens),
|
727 | i,
|
728 | length;
|
729 |
|
730 | for (i = 0, length = array.length; i < length; i++) {
|
731 | if (formatTokenFunctions[array[i]]) {
|
732 | array[i] = formatTokenFunctions[array[i]];
|
733 | } else {
|
734 | array[i] = removeFormattingTokens(array[i]);
|
735 | }
|
736 | }
|
737 |
|
738 | return function (mom) {
|
739 | var output = '',
|
740 | i;
|
741 |
|
742 | for (i = 0; i < length; i++) {
|
743 | output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
|
744 | }
|
745 |
|
746 | return output;
|
747 | };
|
748 | }
|
749 |
|
750 |
|
751 | function formatMoment(m, format) {
|
752 | if (!m.isValid()) {
|
753 | return m.localeData().invalidDate();
|
754 | }
|
755 |
|
756 | format = expandFormat(format, m.localeData());
|
757 | formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
|
758 | return formatFunctions[format](m);
|
759 | }
|
760 |
|
761 | function expandFormat(format, locale) {
|
762 | var i = 5;
|
763 |
|
764 | function replaceLongDateFormatTokens(input) {
|
765 | return locale.longDateFormat(input) || input;
|
766 | }
|
767 |
|
768 | localFormattingTokens.lastIndex = 0;
|
769 |
|
770 | while (i >= 0 && localFormattingTokens.test(format)) {
|
771 | format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
772 | localFormattingTokens.lastIndex = 0;
|
773 | i -= 1;
|
774 | }
|
775 |
|
776 | return format;
|
777 | }
|
778 |
|
779 | var match1 = /\d/;
|
780 |
|
781 | var match2 = /\d\d/;
|
782 |
|
783 | var match3 = /\d{3}/;
|
784 |
|
785 | var match4 = /\d{4}/;
|
786 |
|
787 | var match6 = /[+-]?\d{6}/;
|
788 |
|
789 | var match1to2 = /\d\d?/;
|
790 |
|
791 | var match3to4 = /\d\d\d\d?/;
|
792 |
|
793 | var match5to6 = /\d\d\d\d\d\d?/;
|
794 |
|
795 | var match1to3 = /\d{1,3}/;
|
796 |
|
797 | var match1to4 = /\d{1,4}/;
|
798 |
|
799 | var match1to6 = /[+-]?\d{1,6}/;
|
800 |
|
801 | var matchUnsigned = /\d+/;
|
802 |
|
803 | var matchSigned = /[+-]?\d+/;
|
804 |
|
805 | var matchOffset = /Z|[+-]\d\d:?\d\d/gi;
|
806 |
|
807 | var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi;
|
808 |
|
809 | var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
810 |
|
811 |
|
812 |
|
813 | var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
|
814 | var regexes = {};
|
815 |
|
816 | function addRegexToken(token, regex, strictRegex) {
|
817 | regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
|
818 | return isStrict && strictRegex ? strictRegex : regex;
|
819 | };
|
820 | }
|
821 |
|
822 | function getParseRegexForToken(token, config) {
|
823 | if (!hasOwnProp(regexes, token)) {
|
824 | return new RegExp(unescapeFormat(token));
|
825 | }
|
826 |
|
827 | return regexes[token](config._strict, config._locale);
|
828 | }
|
829 |
|
830 |
|
831 | function unescapeFormat(s) {
|
832 | return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
|
833 | return p1 || p2 || p3 || p4;
|
834 | }));
|
835 | }
|
836 |
|
837 | function regexEscape(s) {
|
838 | return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
839 | }
|
840 |
|
841 | var tokens = {};
|
842 |
|
843 | function addParseToken(token, callback) {
|
844 | var i,
|
845 | func = callback;
|
846 |
|
847 | if (typeof token === 'string') {
|
848 | token = [token];
|
849 | }
|
850 |
|
851 | if (isNumber(callback)) {
|
852 | func = function (input, array) {
|
853 | array[callback] = toInt(input);
|
854 | };
|
855 | }
|
856 |
|
857 | for (i = 0; i < token.length; i++) {
|
858 | tokens[token[i]] = func;
|
859 | }
|
860 | }
|
861 |
|
862 | function addWeekParseToken(token, callback) {
|
863 | addParseToken(token, function (input, array, config, token) {
|
864 | config._w = config._w || {};
|
865 | callback(input, config._w, config, token);
|
866 | });
|
867 | }
|
868 |
|
869 | function addTimeToArrayFromToken(token, input, config) {
|
870 | if (input != null && hasOwnProp(tokens, token)) {
|
871 | tokens[token](input, config._a, config, token);
|
872 | }
|
873 | }
|
874 |
|
875 | var YEAR = 0;
|
876 | var MONTH = 1;
|
877 | var DATE = 2;
|
878 | var HOUR = 3;
|
879 | var MINUTE = 4;
|
880 | var SECOND = 5;
|
881 | var MILLISECOND = 6;
|
882 | var WEEK = 7;
|
883 | var WEEKDAY = 8;
|
884 |
|
885 | addFormatToken('Y', 0, 0, function () {
|
886 | var y = this.year();
|
887 | return y <= 9999 ? '' + y : '+' + y;
|
888 | });
|
889 | addFormatToken(0, ['YY', 2], 0, function () {
|
890 | return this.year() % 100;
|
891 | });
|
892 | addFormatToken(0, ['YYYY', 4], 0, 'year');
|
893 | addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
894 | addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
895 |
|
896 | addUnitAlias('year', 'y');
|
897 |
|
898 | addUnitPriority('year', 1);
|
899 |
|
900 | addRegexToken('Y', matchSigned);
|
901 | addRegexToken('YY', match1to2, match2);
|
902 | addRegexToken('YYYY', match1to4, match4);
|
903 | addRegexToken('YYYYY', match1to6, match6);
|
904 | addRegexToken('YYYYYY', match1to6, match6);
|
905 | addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
906 | addParseToken('YYYY', function (input, array) {
|
907 | array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
|
908 | });
|
909 | addParseToken('YY', function (input, array) {
|
910 | array[YEAR] = hooks.parseTwoDigitYear(input);
|
911 | });
|
912 | addParseToken('Y', function (input, array) {
|
913 | array[YEAR] = parseInt(input, 10);
|
914 | });
|
915 |
|
916 | function daysInYear(year) {
|
917 | return isLeapYear(year) ? 366 : 365;
|
918 | }
|
919 |
|
920 | function isLeapYear(year) {
|
921 | return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
922 | }
|
923 |
|
924 |
|
925 | hooks.parseTwoDigitYear = function (input) {
|
926 | return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
927 | };
|
928 |
|
929 |
|
930 | var getSetYear = makeGetSet('FullYear', true);
|
931 |
|
932 | function getIsLeapYear() {
|
933 | return isLeapYear(this.year());
|
934 | }
|
935 |
|
936 | function makeGetSet(unit, keepTime) {
|
937 | return function (value) {
|
938 | if (value != null) {
|
939 | set$1(this, unit, value);
|
940 | hooks.updateOffset(this, keepTime);
|
941 | return this;
|
942 | } else {
|
943 | return get(this, unit);
|
944 | }
|
945 | };
|
946 | }
|
947 |
|
948 | function get(mom, unit) {
|
949 | return mom.isValid() ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
|
950 | }
|
951 |
|
952 | function set$1(mom, unit, value) {
|
953 | if (mom.isValid() && !isNaN(value)) {
|
954 | if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
|
955 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
|
956 | } else {
|
957 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
958 | }
|
959 | }
|
960 | }
|
961 |
|
962 |
|
963 | function stringGet(units) {
|
964 | units = normalizeUnits(units);
|
965 |
|
966 | if (isFunction(this[units])) {
|
967 | return this[units]();
|
968 | }
|
969 |
|
970 | return this;
|
971 | }
|
972 |
|
973 | function stringSet(units, value) {
|
974 | if (typeof units === 'object') {
|
975 | units = normalizeObjectUnits(units);
|
976 | var prioritized = getPrioritizedUnits(units);
|
977 |
|
978 | for (var i = 0; i < prioritized.length; i++) {
|
979 | this[prioritized[i].unit](units[prioritized[i].unit]);
|
980 | }
|
981 | } else {
|
982 | units = normalizeUnits(units);
|
983 |
|
984 | if (isFunction(this[units])) {
|
985 | return this[units](value);
|
986 | }
|
987 | }
|
988 |
|
989 | return this;
|
990 | }
|
991 |
|
992 | function mod(n, x) {
|
993 | return (n % x + x) % x;
|
994 | }
|
995 |
|
996 | var indexOf;
|
997 |
|
998 | if (Array.prototype.indexOf) {
|
999 | indexOf = Array.prototype.indexOf;
|
1000 | } else {
|
1001 | indexOf = function (o) {
|
1002 |
|
1003 | var i;
|
1004 |
|
1005 | for (i = 0; i < this.length; ++i) {
|
1006 | if (this[i] === o) {
|
1007 | return i;
|
1008 | }
|
1009 | }
|
1010 |
|
1011 | return -1;
|
1012 | };
|
1013 | }
|
1014 |
|
1015 | function daysInMonth(year, month) {
|
1016 | if (isNaN(year) || isNaN(month)) {
|
1017 | return NaN;
|
1018 | }
|
1019 |
|
1020 | var modMonth = mod(month, 12);
|
1021 | year += (month - modMonth) / 12;
|
1022 | return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - modMonth % 7 % 2;
|
1023 | }
|
1024 |
|
1025 |
|
1026 | addFormatToken('M', ['MM', 2], 'Mo', function () {
|
1027 | return this.month() + 1;
|
1028 | });
|
1029 | addFormatToken('MMM', 0, 0, function (format) {
|
1030 | return this.localeData().monthsShort(this, format);
|
1031 | });
|
1032 | addFormatToken('MMMM', 0, 0, function (format) {
|
1033 | return this.localeData().months(this, format);
|
1034 | });
|
1035 |
|
1036 | addUnitAlias('month', 'M');
|
1037 |
|
1038 | addUnitPriority('month', 8);
|
1039 |
|
1040 | addRegexToken('M', match1to2);
|
1041 | addRegexToken('MM', match1to2, match2);
|
1042 | addRegexToken('MMM', function (isStrict, locale) {
|
1043 | return locale.monthsShortRegex(isStrict);
|
1044 | });
|
1045 | addRegexToken('MMMM', function (isStrict, locale) {
|
1046 | return locale.monthsRegex(isStrict);
|
1047 | });
|
1048 | addParseToken(['M', 'MM'], function (input, array) {
|
1049 | array[MONTH] = toInt(input) - 1;
|
1050 | });
|
1051 | addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
|
1052 | var month = config._locale.monthsParse(input, token, config._strict);
|
1053 |
|
1054 |
|
1055 | if (month != null) {
|
1056 | array[MONTH] = month;
|
1057 | } else {
|
1058 | getParsingFlags(config).invalidMonth = input;
|
1059 | }
|
1060 | });
|
1061 |
|
1062 | var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
|
1063 | var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
1064 |
|
1065 | function localeMonths(m, format) {
|
1066 | if (!m) {
|
1067 | return isArray(this._months) ? this._months : this._months['standalone'];
|
1068 | }
|
1069 |
|
1070 | return isArray(this._months) ? this._months[m.month()] : this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
|
1071 | }
|
1072 |
|
1073 | var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
1074 |
|
1075 | function localeMonthsShort(m, format) {
|
1076 | if (!m) {
|
1077 | return isArray(this._monthsShort) ? this._monthsShort : this._monthsShort['standalone'];
|
1078 | }
|
1079 |
|
1080 | return isArray(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
1081 | }
|
1082 |
|
1083 | function handleStrictParse(monthName, format, strict) {
|
1084 | var i,
|
1085 | ii,
|
1086 | mom,
|
1087 | llc = monthName.toLocaleLowerCase();
|
1088 |
|
1089 | if (!this._monthsParse) {
|
1090 |
|
1091 | this._monthsParse = [];
|
1092 | this._longMonthsParse = [];
|
1093 | this._shortMonthsParse = [];
|
1094 |
|
1095 | for (i = 0; i < 12; ++i) {
|
1096 | mom = createUTC([2000, i]);
|
1097 | this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
1098 | this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
1099 | }
|
1100 | }
|
1101 |
|
1102 | if (strict) {
|
1103 | if (format === 'MMM') {
|
1104 | ii = indexOf.call(this._shortMonthsParse, llc);
|
1105 | return ii !== -1 ? ii : null;
|
1106 | } else {
|
1107 | ii = indexOf.call(this._longMonthsParse, llc);
|
1108 | return ii !== -1 ? ii : null;
|
1109 | }
|
1110 | } else {
|
1111 | if (format === 'MMM') {
|
1112 | ii = indexOf.call(this._shortMonthsParse, llc);
|
1113 |
|
1114 | if (ii !== -1) {
|
1115 | return ii;
|
1116 | }
|
1117 |
|
1118 | ii = indexOf.call(this._longMonthsParse, llc);
|
1119 | return ii !== -1 ? ii : null;
|
1120 | } else {
|
1121 | ii = indexOf.call(this._longMonthsParse, llc);
|
1122 |
|
1123 | if (ii !== -1) {
|
1124 | return ii;
|
1125 | }
|
1126 |
|
1127 | ii = indexOf.call(this._shortMonthsParse, llc);
|
1128 | return ii !== -1 ? ii : null;
|
1129 | }
|
1130 | }
|
1131 | }
|
1132 |
|
1133 | function localeMonthsParse(monthName, format, strict) {
|
1134 | var i, mom, regex;
|
1135 |
|
1136 | if (this._monthsParseExact) {
|
1137 | return handleStrictParse.call(this, monthName, format, strict);
|
1138 | }
|
1139 |
|
1140 | if (!this._monthsParse) {
|
1141 | this._monthsParse = [];
|
1142 | this._longMonthsParse = [];
|
1143 | this._shortMonthsParse = [];
|
1144 | }
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 | for (i = 0; i < 12; i++) {
|
1150 |
|
1151 | mom = createUTC([2000, i]);
|
1152 |
|
1153 | if (strict && !this._longMonthsParse[i]) {
|
1154 | this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
1155 | this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
1156 | }
|
1157 |
|
1158 | if (!strict && !this._monthsParse[i]) {
|
1159 | regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
1160 | this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
1161 | }
|
1162 |
|
1163 |
|
1164 | if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
|
1165 | return i;
|
1166 | } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
|
1167 | return i;
|
1168 | } else if (!strict && this._monthsParse[i].test(monthName)) {
|
1169 | return i;
|
1170 | }
|
1171 | }
|
1172 | }
|
1173 |
|
1174 |
|
1175 | function setMonth(mom, value) {
|
1176 | var dayOfMonth;
|
1177 |
|
1178 | if (!mom.isValid()) {
|
1179 |
|
1180 | return mom;
|
1181 | }
|
1182 |
|
1183 | if (typeof value === 'string') {
|
1184 | if (/^\d+$/.test(value)) {
|
1185 | value = toInt(value);
|
1186 | } else {
|
1187 | value = mom.localeData().monthsParse(value);
|
1188 |
|
1189 | if (!isNumber(value)) {
|
1190 | return mom;
|
1191 | }
|
1192 | }
|
1193 | }
|
1194 |
|
1195 | dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
|
1196 |
|
1197 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
1198 |
|
1199 | return mom;
|
1200 | }
|
1201 |
|
1202 | function getSetMonth(value) {
|
1203 | if (value != null) {
|
1204 | setMonth(this, value);
|
1205 | hooks.updateOffset(this, true);
|
1206 | return this;
|
1207 | } else {
|
1208 | return get(this, 'Month');
|
1209 | }
|
1210 | }
|
1211 |
|
1212 | function getDaysInMonth() {
|
1213 | return daysInMonth(this.year(), this.month());
|
1214 | }
|
1215 |
|
1216 | var defaultMonthsShortRegex = matchWord;
|
1217 |
|
1218 | function monthsShortRegex(isStrict) {
|
1219 | if (this._monthsParseExact) {
|
1220 | if (!hasOwnProp(this, '_monthsRegex')) {
|
1221 | computeMonthsParse.call(this);
|
1222 | }
|
1223 |
|
1224 | if (isStrict) {
|
1225 | return this._monthsShortStrictRegex;
|
1226 | } else {
|
1227 | return this._monthsShortRegex;
|
1228 | }
|
1229 | } else {
|
1230 | if (!hasOwnProp(this, '_monthsShortRegex')) {
|
1231 | this._monthsShortRegex = defaultMonthsShortRegex;
|
1232 | }
|
1233 |
|
1234 | return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex;
|
1235 | }
|
1236 | }
|
1237 |
|
1238 | var defaultMonthsRegex = matchWord;
|
1239 |
|
1240 | function monthsRegex(isStrict) {
|
1241 | if (this._monthsParseExact) {
|
1242 | if (!hasOwnProp(this, '_monthsRegex')) {
|
1243 | computeMonthsParse.call(this);
|
1244 | }
|
1245 |
|
1246 | if (isStrict) {
|
1247 | return this._monthsStrictRegex;
|
1248 | } else {
|
1249 | return this._monthsRegex;
|
1250 | }
|
1251 | } else {
|
1252 | if (!hasOwnProp(this, '_monthsRegex')) {
|
1253 | this._monthsRegex = defaultMonthsRegex;
|
1254 | }
|
1255 |
|
1256 | return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex;
|
1257 | }
|
1258 | }
|
1259 |
|
1260 | function computeMonthsParse() {
|
1261 | function cmpLenRev(a, b) {
|
1262 | return b.length - a.length;
|
1263 | }
|
1264 |
|
1265 | var shortPieces = [],
|
1266 | longPieces = [],
|
1267 | mixedPieces = [],
|
1268 | i,
|
1269 | mom;
|
1270 |
|
1271 | for (i = 0; i < 12; i++) {
|
1272 |
|
1273 | mom = createUTC([2000, i]);
|
1274 | shortPieces.push(this.monthsShort(mom, ''));
|
1275 | longPieces.push(this.months(mom, ''));
|
1276 | mixedPieces.push(this.months(mom, ''));
|
1277 | mixedPieces.push(this.monthsShort(mom, ''));
|
1278 | }
|
1279 |
|
1280 |
|
1281 |
|
1282 | shortPieces.sort(cmpLenRev);
|
1283 | longPieces.sort(cmpLenRev);
|
1284 | mixedPieces.sort(cmpLenRev);
|
1285 |
|
1286 | for (i = 0; i < 12; i++) {
|
1287 | shortPieces[i] = regexEscape(shortPieces[i]);
|
1288 | longPieces[i] = regexEscape(longPieces[i]);
|
1289 | }
|
1290 |
|
1291 | for (i = 0; i < 24; i++) {
|
1292 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
1293 | }
|
1294 |
|
1295 | this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
1296 | this._monthsShortRegex = this._monthsRegex;
|
1297 | this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
1298 | this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
1299 | }
|
1300 |
|
1301 | function createDate(y, m, d, h, M, s, ms) {
|
1302 |
|
1303 |
|
1304 | var date;
|
1305 |
|
1306 | if (y < 100 && y >= 0) {
|
1307 |
|
1308 | date = new Date(y + 400, m, d, h, M, s, ms);
|
1309 |
|
1310 | if (isFinite(date.getFullYear())) {
|
1311 | date.setFullYear(y);
|
1312 | }
|
1313 | } else {
|
1314 | date = new Date(y, m, d, h, M, s, ms);
|
1315 | }
|
1316 |
|
1317 | return date;
|
1318 | }
|
1319 |
|
1320 | function createUTCDate(y) {
|
1321 | var date;
|
1322 |
|
1323 | if (y < 100 && y >= 0) {
|
1324 | var args = Array.prototype.slice.call(arguments);
|
1325 |
|
1326 | args[0] = y + 400;
|
1327 | date = new Date(Date.UTC.apply(null, args));
|
1328 |
|
1329 | if (isFinite(date.getUTCFullYear())) {
|
1330 | date.setUTCFullYear(y);
|
1331 | }
|
1332 | } else {
|
1333 | date = new Date(Date.UTC.apply(null, arguments));
|
1334 | }
|
1335 |
|
1336 | return date;
|
1337 | }
|
1338 |
|
1339 |
|
1340 | function firstWeekOffset(year, dow, doy) {
|
1341 | var
|
1342 | fwd = 7 + dow - doy,
|
1343 |
|
1344 | fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
1345 | return -fwdlw + fwd - 1;
|
1346 | }
|
1347 |
|
1348 |
|
1349 | function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
1350 | var localWeekday = (7 + weekday - dow) % 7,
|
1351 | weekOffset = firstWeekOffset(year, dow, doy),
|
1352 | dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
1353 | resYear,
|
1354 | resDayOfYear;
|
1355 |
|
1356 | if (dayOfYear <= 0) {
|
1357 | resYear = year - 1;
|
1358 | resDayOfYear = daysInYear(resYear) + dayOfYear;
|
1359 | } else if (dayOfYear > daysInYear(year)) {
|
1360 | resYear = year + 1;
|
1361 | resDayOfYear = dayOfYear - daysInYear(year);
|
1362 | } else {
|
1363 | resYear = year;
|
1364 | resDayOfYear = dayOfYear;
|
1365 | }
|
1366 |
|
1367 | return {
|
1368 | year: resYear,
|
1369 | dayOfYear: resDayOfYear
|
1370 | };
|
1371 | }
|
1372 |
|
1373 | function weekOfYear(mom, dow, doy) {
|
1374 | var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
1375 | week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
1376 | resWeek,
|
1377 | resYear;
|
1378 |
|
1379 | if (week < 1) {
|
1380 | resYear = mom.year() - 1;
|
1381 | resWeek = week + weeksInYear(resYear, dow, doy);
|
1382 | } else if (week > weeksInYear(mom.year(), dow, doy)) {
|
1383 | resWeek = week - weeksInYear(mom.year(), dow, doy);
|
1384 | resYear = mom.year() + 1;
|
1385 | } else {
|
1386 | resYear = mom.year();
|
1387 | resWeek = week;
|
1388 | }
|
1389 |
|
1390 | return {
|
1391 | week: resWeek,
|
1392 | year: resYear
|
1393 | };
|
1394 | }
|
1395 |
|
1396 | function weeksInYear(year, dow, doy) {
|
1397 | var weekOffset = firstWeekOffset(year, dow, doy),
|
1398 | weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
1399 | return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
1400 | }
|
1401 |
|
1402 |
|
1403 | addFormatToken('w', ['ww', 2], 'wo', 'week');
|
1404 | addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
1405 |
|
1406 | addUnitAlias('week', 'w');
|
1407 | addUnitAlias('isoWeek', 'W');
|
1408 |
|
1409 | addUnitPriority('week', 5);
|
1410 | addUnitPriority('isoWeek', 5);
|
1411 |
|
1412 | addRegexToken('w', match1to2);
|
1413 | addRegexToken('ww', match1to2, match2);
|
1414 | addRegexToken('W', match1to2);
|
1415 | addRegexToken('WW', match1to2, match2);
|
1416 | addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
1417 | week[token.substr(0, 1)] = toInt(input);
|
1418 | });
|
1419 |
|
1420 |
|
1421 | function localeWeek(mom) {
|
1422 | return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
1423 | }
|
1424 |
|
1425 | var defaultLocaleWeek = {
|
1426 | dow: 0,
|
1427 |
|
1428 | doy: 6
|
1429 |
|
1430 | };
|
1431 |
|
1432 | function localeFirstDayOfWeek() {
|
1433 | return this._week.dow;
|
1434 | }
|
1435 |
|
1436 | function localeFirstDayOfYear() {
|
1437 | return this._week.doy;
|
1438 | }
|
1439 |
|
1440 |
|
1441 | function getSetWeek(input) {
|
1442 | var week = this.localeData().week(this);
|
1443 | return input == null ? week : this.add((input - week) * 7, 'd');
|
1444 | }
|
1445 |
|
1446 | function getSetISOWeek(input) {
|
1447 | var week = weekOfYear(this, 1, 4).week;
|
1448 | return input == null ? week : this.add((input - week) * 7, 'd');
|
1449 | }
|
1450 |
|
1451 |
|
1452 | addFormatToken('d', 0, 'do', 'day');
|
1453 | addFormatToken('dd', 0, 0, function (format) {
|
1454 | return this.localeData().weekdaysMin(this, format);
|
1455 | });
|
1456 | addFormatToken('ddd', 0, 0, function (format) {
|
1457 | return this.localeData().weekdaysShort(this, format);
|
1458 | });
|
1459 | addFormatToken('dddd', 0, 0, function (format) {
|
1460 | return this.localeData().weekdays(this, format);
|
1461 | });
|
1462 | addFormatToken('e', 0, 0, 'weekday');
|
1463 | addFormatToken('E', 0, 0, 'isoWeekday');
|
1464 |
|
1465 | addUnitAlias('day', 'd');
|
1466 | addUnitAlias('weekday', 'e');
|
1467 | addUnitAlias('isoWeekday', 'E');
|
1468 |
|
1469 | addUnitPriority('day', 11);
|
1470 | addUnitPriority('weekday', 11);
|
1471 | addUnitPriority('isoWeekday', 11);
|
1472 |
|
1473 | addRegexToken('d', match1to2);
|
1474 | addRegexToken('e', match1to2);
|
1475 | addRegexToken('E', match1to2);
|
1476 | addRegexToken('dd', function (isStrict, locale) {
|
1477 | return locale.weekdaysMinRegex(isStrict);
|
1478 | });
|
1479 | addRegexToken('ddd', function (isStrict, locale) {
|
1480 | return locale.weekdaysShortRegex(isStrict);
|
1481 | });
|
1482 | addRegexToken('dddd', function (isStrict, locale) {
|
1483 | return locale.weekdaysRegex(isStrict);
|
1484 | });
|
1485 | addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
1486 | var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
1487 |
|
1488 |
|
1489 | if (weekday != null) {
|
1490 | week.d = weekday;
|
1491 | } else {
|
1492 | getParsingFlags(config).invalidWeekday = input;
|
1493 | }
|
1494 | });
|
1495 | addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
1496 | week[token] = toInt(input);
|
1497 | });
|
1498 |
|
1499 | function parseWeekday(input, locale) {
|
1500 | if (typeof input !== 'string') {
|
1501 | return input;
|
1502 | }
|
1503 |
|
1504 | if (!isNaN(input)) {
|
1505 | return parseInt(input, 10);
|
1506 | }
|
1507 |
|
1508 | input = locale.weekdaysParse(input);
|
1509 |
|
1510 | if (typeof input === 'number') {
|
1511 | return input;
|
1512 | }
|
1513 |
|
1514 | return null;
|
1515 | }
|
1516 |
|
1517 | function parseIsoWeekday(input, locale) {
|
1518 | if (typeof input === 'string') {
|
1519 | return locale.weekdaysParse(input) % 7 || 7;
|
1520 | }
|
1521 |
|
1522 | return isNaN(input) ? null : input;
|
1523 | }
|
1524 |
|
1525 |
|
1526 | function shiftWeekdays(ws, n) {
|
1527 | return ws.slice(n, 7).concat(ws.slice(0, n));
|
1528 | }
|
1529 |
|
1530 | var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
1531 |
|
1532 | function localeWeekdays(m, format) {
|
1533 | var weekdays = isArray(this._weekdays) ? this._weekdays : this._weekdays[m && m !== true && this._weekdays.isFormat.test(format) ? 'format' : 'standalone'];
|
1534 | return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays;
|
1535 | }
|
1536 |
|
1537 | var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
1538 |
|
1539 | function localeWeekdaysShort(m) {
|
1540 | return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
1541 | }
|
1542 |
|
1543 | var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
1544 |
|
1545 | function localeWeekdaysMin(m) {
|
1546 | return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
1547 | }
|
1548 |
|
1549 | function handleStrictParse$1(weekdayName, format, strict) {
|
1550 | var i,
|
1551 | ii,
|
1552 | mom,
|
1553 | llc = weekdayName.toLocaleLowerCase();
|
1554 |
|
1555 | if (!this._weekdaysParse) {
|
1556 | this._weekdaysParse = [];
|
1557 | this._shortWeekdaysParse = [];
|
1558 | this._minWeekdaysParse = [];
|
1559 |
|
1560 | for (i = 0; i < 7; ++i) {
|
1561 | mom = createUTC([2000, 1]).day(i);
|
1562 | this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
1563 | this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
1564 | this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
1565 | }
|
1566 | }
|
1567 |
|
1568 | if (strict) {
|
1569 | if (format === 'dddd') {
|
1570 | ii = indexOf.call(this._weekdaysParse, llc);
|
1571 | return ii !== -1 ? ii : null;
|
1572 | } else if (format === 'ddd') {
|
1573 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1574 | return ii !== -1 ? ii : null;
|
1575 | } else {
|
1576 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
1577 | return ii !== -1 ? ii : null;
|
1578 | }
|
1579 | } else {
|
1580 | if (format === 'dddd') {
|
1581 | ii = indexOf.call(this._weekdaysParse, llc);
|
1582 |
|
1583 | if (ii !== -1) {
|
1584 | return ii;
|
1585 | }
|
1586 |
|
1587 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1588 |
|
1589 | if (ii !== -1) {
|
1590 | return ii;
|
1591 | }
|
1592 |
|
1593 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
1594 | return ii !== -1 ? ii : null;
|
1595 | } else if (format === 'ddd') {
|
1596 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1597 |
|
1598 | if (ii !== -1) {
|
1599 | return ii;
|
1600 | }
|
1601 |
|
1602 | ii = indexOf.call(this._weekdaysParse, llc);
|
1603 |
|
1604 | if (ii !== -1) {
|
1605 | return ii;
|
1606 | }
|
1607 |
|
1608 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
1609 | return ii !== -1 ? ii : null;
|
1610 | } else {
|
1611 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
1612 |
|
1613 | if (ii !== -1) {
|
1614 | return ii;
|
1615 | }
|
1616 |
|
1617 | ii = indexOf.call(this._weekdaysParse, llc);
|
1618 |
|
1619 | if (ii !== -1) {
|
1620 | return ii;
|
1621 | }
|
1622 |
|
1623 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
1624 | return ii !== -1 ? ii : null;
|
1625 | }
|
1626 | }
|
1627 | }
|
1628 |
|
1629 | function localeWeekdaysParse(weekdayName, format, strict) {
|
1630 | var i, mom, regex;
|
1631 |
|
1632 | if (this._weekdaysParseExact) {
|
1633 | return handleStrictParse$1.call(this, weekdayName, format, strict);
|
1634 | }
|
1635 |
|
1636 | if (!this._weekdaysParse) {
|
1637 | this._weekdaysParse = [];
|
1638 | this._minWeekdaysParse = [];
|
1639 | this._shortWeekdaysParse = [];
|
1640 | this._fullWeekdaysParse = [];
|
1641 | }
|
1642 |
|
1643 | for (i = 0; i < 7; i++) {
|
1644 |
|
1645 | mom = createUTC([2000, 1]).day(i);
|
1646 |
|
1647 | if (strict && !this._fullWeekdaysParse[i]) {
|
1648 | this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
|
1649 | this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
|
1650 | this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
|
1651 | }
|
1652 |
|
1653 | if (!this._weekdaysParse[i]) {
|
1654 | regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
1655 | this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
1656 | }
|
1657 |
|
1658 |
|
1659 | if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
1660 | return i;
|
1661 | } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
1662 | return i;
|
1663 | } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
1664 | return i;
|
1665 | } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
1666 | return i;
|
1667 | }
|
1668 | }
|
1669 | }
|
1670 |
|
1671 |
|
1672 | function getSetDayOfWeek(input) {
|
1673 | if (!this.isValid()) {
|
1674 | return input != null ? this : NaN;
|
1675 | }
|
1676 |
|
1677 | var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
1678 |
|
1679 | if (input != null) {
|
1680 | input = parseWeekday(input, this.localeData());
|
1681 | return this.add(input - day, 'd');
|
1682 | } else {
|
1683 | return day;
|
1684 | }
|
1685 | }
|
1686 |
|
1687 | function getSetLocaleDayOfWeek(input) {
|
1688 | if (!this.isValid()) {
|
1689 | return input != null ? this : NaN;
|
1690 | }
|
1691 |
|
1692 | var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
1693 | return input == null ? weekday : this.add(input - weekday, 'd');
|
1694 | }
|
1695 |
|
1696 | function getSetISODayOfWeek(input) {
|
1697 | if (!this.isValid()) {
|
1698 | return input != null ? this : NaN;
|
1699 | }
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 | if (input != null) {
|
1705 | var weekday = parseIsoWeekday(input, this.localeData());
|
1706 | return this.day(this.day() % 7 ? weekday : weekday - 7);
|
1707 | } else {
|
1708 | return this.day() || 7;
|
1709 | }
|
1710 | }
|
1711 |
|
1712 | var defaultWeekdaysRegex = matchWord;
|
1713 |
|
1714 | function weekdaysRegex(isStrict) {
|
1715 | if (this._weekdaysParseExact) {
|
1716 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1717 | computeWeekdaysParse.call(this);
|
1718 | }
|
1719 |
|
1720 | if (isStrict) {
|
1721 | return this._weekdaysStrictRegex;
|
1722 | } else {
|
1723 | return this._weekdaysRegex;
|
1724 | }
|
1725 | } else {
|
1726 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1727 | this._weekdaysRegex = defaultWeekdaysRegex;
|
1728 | }
|
1729 |
|
1730 | return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex;
|
1731 | }
|
1732 | }
|
1733 |
|
1734 | var defaultWeekdaysShortRegex = matchWord;
|
1735 |
|
1736 | function weekdaysShortRegex(isStrict) {
|
1737 | if (this._weekdaysParseExact) {
|
1738 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1739 | computeWeekdaysParse.call(this);
|
1740 | }
|
1741 |
|
1742 | if (isStrict) {
|
1743 | return this._weekdaysShortStrictRegex;
|
1744 | } else {
|
1745 | return this._weekdaysShortRegex;
|
1746 | }
|
1747 | } else {
|
1748 | if (!hasOwnProp(this, '_weekdaysShortRegex')) {
|
1749 | this._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
1750 | }
|
1751 |
|
1752 | return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
1753 | }
|
1754 | }
|
1755 |
|
1756 | var defaultWeekdaysMinRegex = matchWord;
|
1757 |
|
1758 | function weekdaysMinRegex(isStrict) {
|
1759 | if (this._weekdaysParseExact) {
|
1760 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
1761 | computeWeekdaysParse.call(this);
|
1762 | }
|
1763 |
|
1764 | if (isStrict) {
|
1765 | return this._weekdaysMinStrictRegex;
|
1766 | } else {
|
1767 | return this._weekdaysMinRegex;
|
1768 | }
|
1769 | } else {
|
1770 | if (!hasOwnProp(this, '_weekdaysMinRegex')) {
|
1771 | this._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
1772 | }
|
1773 |
|
1774 | return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
|
1775 | }
|
1776 | }
|
1777 |
|
1778 | function computeWeekdaysParse() {
|
1779 | function cmpLenRev(a, b) {
|
1780 | return b.length - a.length;
|
1781 | }
|
1782 |
|
1783 | var minPieces = [],
|
1784 | shortPieces = [],
|
1785 | longPieces = [],
|
1786 | mixedPieces = [],
|
1787 | i,
|
1788 | mom,
|
1789 | minp,
|
1790 | shortp,
|
1791 | longp;
|
1792 |
|
1793 | for (i = 0; i < 7; i++) {
|
1794 |
|
1795 | mom = createUTC([2000, 1]).day(i);
|
1796 | minp = this.weekdaysMin(mom, '');
|
1797 | shortp = this.weekdaysShort(mom, '');
|
1798 | longp = this.weekdays(mom, '');
|
1799 | minPieces.push(minp);
|
1800 | shortPieces.push(shortp);
|
1801 | longPieces.push(longp);
|
1802 | mixedPieces.push(minp);
|
1803 | mixedPieces.push(shortp);
|
1804 | mixedPieces.push(longp);
|
1805 | }
|
1806 |
|
1807 |
|
1808 |
|
1809 | minPieces.sort(cmpLenRev);
|
1810 | shortPieces.sort(cmpLenRev);
|
1811 | longPieces.sort(cmpLenRev);
|
1812 | mixedPieces.sort(cmpLenRev);
|
1813 |
|
1814 | for (i = 0; i < 7; i++) {
|
1815 | shortPieces[i] = regexEscape(shortPieces[i]);
|
1816 | longPieces[i] = regexEscape(longPieces[i]);
|
1817 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
1818 | }
|
1819 |
|
1820 | this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
1821 | this._weekdaysShortRegex = this._weekdaysRegex;
|
1822 | this._weekdaysMinRegex = this._weekdaysRegex;
|
1823 | this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
1824 | this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
1825 | this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
|
1826 | }
|
1827 |
|
1828 |
|
1829 | function hFormat() {
|
1830 | return this.hours() % 12 || 12;
|
1831 | }
|
1832 |
|
1833 | function kFormat() {
|
1834 | return this.hours() || 24;
|
1835 | }
|
1836 |
|
1837 | addFormatToken('H', ['HH', 2], 0, 'hour');
|
1838 | addFormatToken('h', ['hh', 2], 0, hFormat);
|
1839 | addFormatToken('k', ['kk', 2], 0, kFormat);
|
1840 | addFormatToken('hmm', 0, 0, function () {
|
1841 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
1842 | });
|
1843 | addFormatToken('hmmss', 0, 0, function () {
|
1844 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
1845 | });
|
1846 | addFormatToken('Hmm', 0, 0, function () {
|
1847 | return '' + this.hours() + zeroFill(this.minutes(), 2);
|
1848 | });
|
1849 | addFormatToken('Hmmss', 0, 0, function () {
|
1850 | return '' + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
1851 | });
|
1852 |
|
1853 | function meridiem(token, lowercase) {
|
1854 | addFormatToken(token, 0, 0, function () {
|
1855 | return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
1856 | });
|
1857 | }
|
1858 |
|
1859 | meridiem('a', true);
|
1860 | meridiem('A', false);
|
1861 |
|
1862 | addUnitAlias('hour', 'h');
|
1863 |
|
1864 | addUnitPriority('hour', 13);
|
1865 |
|
1866 | function matchMeridiem(isStrict, locale) {
|
1867 | return locale._meridiemParse;
|
1868 | }
|
1869 |
|
1870 | addRegexToken('a', matchMeridiem);
|
1871 | addRegexToken('A', matchMeridiem);
|
1872 | addRegexToken('H', match1to2);
|
1873 | addRegexToken('h', match1to2);
|
1874 | addRegexToken('k', match1to2);
|
1875 | addRegexToken('HH', match1to2, match2);
|
1876 | addRegexToken('hh', match1to2, match2);
|
1877 | addRegexToken('kk', match1to2, match2);
|
1878 | addRegexToken('hmm', match3to4);
|
1879 | addRegexToken('hmmss', match5to6);
|
1880 | addRegexToken('Hmm', match3to4);
|
1881 | addRegexToken('Hmmss', match5to6);
|
1882 | addParseToken(['H', 'HH'], HOUR);
|
1883 | addParseToken(['k', 'kk'], function (input, array, config) {
|
1884 | var kInput = toInt(input);
|
1885 | array[HOUR] = kInput === 24 ? 0 : kInput;
|
1886 | });
|
1887 | addParseToken(['a', 'A'], function (input, array, config) {
|
1888 | config._isPm = config._locale.isPM(input);
|
1889 | config._meridiem = input;
|
1890 | });
|
1891 | addParseToken(['h', 'hh'], function (input, array, config) {
|
1892 | array[HOUR] = toInt(input);
|
1893 | getParsingFlags(config).bigHour = true;
|
1894 | });
|
1895 | addParseToken('hmm', function (input, array, config) {
|
1896 | var pos = input.length - 2;
|
1897 | array[HOUR] = toInt(input.substr(0, pos));
|
1898 | array[MINUTE] = toInt(input.substr(pos));
|
1899 | getParsingFlags(config).bigHour = true;
|
1900 | });
|
1901 | addParseToken('hmmss', function (input, array, config) {
|
1902 | var pos1 = input.length - 4;
|
1903 | var pos2 = input.length - 2;
|
1904 | array[HOUR] = toInt(input.substr(0, pos1));
|
1905 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
1906 | array[SECOND] = toInt(input.substr(pos2));
|
1907 | getParsingFlags(config).bigHour = true;
|
1908 | });
|
1909 | addParseToken('Hmm', function (input, array, config) {
|
1910 | var pos = input.length - 2;
|
1911 | array[HOUR] = toInt(input.substr(0, pos));
|
1912 | array[MINUTE] = toInt(input.substr(pos));
|
1913 | });
|
1914 | addParseToken('Hmmss', function (input, array, config) {
|
1915 | var pos1 = input.length - 4;
|
1916 | var pos2 = input.length - 2;
|
1917 | array[HOUR] = toInt(input.substr(0, pos1));
|
1918 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
1919 | array[SECOND] = toInt(input.substr(pos2));
|
1920 | });
|
1921 |
|
1922 | function localeIsPM(input) {
|
1923 |
|
1924 |
|
1925 | return (input + '').toLowerCase().charAt(0) === 'p';
|
1926 | }
|
1927 |
|
1928 | var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
1929 |
|
1930 | function localeMeridiem(hours, minutes, isLower) {
|
1931 | if (hours > 11) {
|
1932 | return isLower ? 'pm' : 'PM';
|
1933 | } else {
|
1934 | return isLower ? 'am' : 'AM';
|
1935 | }
|
1936 | }
|
1937 |
|
1938 |
|
1939 |
|
1940 |
|
1941 |
|
1942 |
|
1943 | var getSetHour = makeGetSet('Hours', true);
|
1944 | var baseConfig = {
|
1945 | calendar: defaultCalendar,
|
1946 | longDateFormat: defaultLongDateFormat,
|
1947 | invalidDate: defaultInvalidDate,
|
1948 | ordinal: defaultOrdinal,
|
1949 | dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
|
1950 | relativeTime: defaultRelativeTime,
|
1951 | months: defaultLocaleMonths,
|
1952 | monthsShort: defaultLocaleMonthsShort,
|
1953 | week: defaultLocaleWeek,
|
1954 | weekdays: defaultLocaleWeekdays,
|
1955 | weekdaysMin: defaultLocaleWeekdaysMin,
|
1956 | weekdaysShort: defaultLocaleWeekdaysShort,
|
1957 | meridiemParse: defaultLocaleMeridiemParse
|
1958 | };
|
1959 |
|
1960 | var locales = {};
|
1961 | var localeFamilies = {};
|
1962 | var globalLocale;
|
1963 |
|
1964 | function normalizeLocale(key) {
|
1965 | return key ? key.toLowerCase().replace('_', '-') : key;
|
1966 | }
|
1967 |
|
1968 |
|
1969 |
|
1970 |
|
1971 | function chooseLocale(names) {
|
1972 | var i = 0,
|
1973 | j,
|
1974 | next,
|
1975 | locale,
|
1976 | split;
|
1977 |
|
1978 | while (i < names.length) {
|
1979 | split = normalizeLocale(names[i]).split('-');
|
1980 | j = split.length;
|
1981 | next = normalizeLocale(names[i + 1]);
|
1982 | next = next ? next.split('-') : null;
|
1983 |
|
1984 | while (j > 0) {
|
1985 | locale = loadLocale(split.slice(0, j).join('-'));
|
1986 |
|
1987 | if (locale) {
|
1988 | return locale;
|
1989 | }
|
1990 |
|
1991 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
1992 |
|
1993 | break;
|
1994 | }
|
1995 |
|
1996 | j--;
|
1997 | }
|
1998 |
|
1999 | i++;
|
2000 | }
|
2001 |
|
2002 | return globalLocale;
|
2003 | }
|
2004 |
|
2005 | function loadLocale(name) {
|
2006 | var oldLocale = null;
|
2007 |
|
2008 | if (!locales[name] && 'object' !== 'undefined' && module && module.exports) {
|
2009 | try {
|
2010 | oldLocale = globalLocale._abbr;
|
2011 | var aliasedRequire = commonjsRequire;
|
2012 | aliasedRequire('./locale/' + name);
|
2013 | getSetGlobalLocale(oldLocale);
|
2014 | } catch (e) {}
|
2015 | }
|
2016 |
|
2017 | return locales[name];
|
2018 | }
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 | function getSetGlobalLocale(key, values) {
|
2024 | var data;
|
2025 |
|
2026 | if (key) {
|
2027 | if (isUndefined(values)) {
|
2028 | data = getLocale(key);
|
2029 | } else {
|
2030 | data = defineLocale(key, values);
|
2031 | }
|
2032 |
|
2033 | if (data) {
|
2034 |
|
2035 | globalLocale = data;
|
2036 | } else {
|
2037 | if (typeof console !== 'undefined' && console.warn) {
|
2038 |
|
2039 | console.warn('Locale ' + key + ' not found. Did you forget to load it?');
|
2040 | }
|
2041 | }
|
2042 | }
|
2043 |
|
2044 | return globalLocale._abbr;
|
2045 | }
|
2046 |
|
2047 | function defineLocale(name, config) {
|
2048 | if (config !== null) {
|
2049 | var locale,
|
2050 | parentConfig = baseConfig;
|
2051 | config.abbr = name;
|
2052 |
|
2053 | if (locales[name] != null) {
|
2054 | deprecateSimple('defineLocaleOverride', 'use moment.updateLocale(localeName, config) to change ' + 'an existing locale. moment.defineLocale(localeName, ' + 'config) should only be used for creating a new locale ' + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
|
2055 | parentConfig = locales[name]._config;
|
2056 | } else if (config.parentLocale != null) {
|
2057 | if (locales[config.parentLocale] != null) {
|
2058 | parentConfig = locales[config.parentLocale]._config;
|
2059 | } else {
|
2060 | locale = loadLocale(config.parentLocale);
|
2061 |
|
2062 | if (locale != null) {
|
2063 | parentConfig = locale._config;
|
2064 | } else {
|
2065 | if (!localeFamilies[config.parentLocale]) {
|
2066 | localeFamilies[config.parentLocale] = [];
|
2067 | }
|
2068 |
|
2069 | localeFamilies[config.parentLocale].push({
|
2070 | name: name,
|
2071 | config: config
|
2072 | });
|
2073 | return null;
|
2074 | }
|
2075 | }
|
2076 | }
|
2077 |
|
2078 | locales[name] = new Locale(mergeConfigs(parentConfig, config));
|
2079 |
|
2080 | if (localeFamilies[name]) {
|
2081 | localeFamilies[name].forEach(function (x) {
|
2082 | defineLocale(x.name, x.config);
|
2083 | });
|
2084 | }
|
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 | getSetGlobalLocale(name);
|
2090 | return locales[name];
|
2091 | } else {
|
2092 |
|
2093 | delete locales[name];
|
2094 | return null;
|
2095 | }
|
2096 | }
|
2097 |
|
2098 | function updateLocale(name, config) {
|
2099 | if (config != null) {
|
2100 | var locale,
|
2101 | tmpLocale,
|
2102 | parentConfig = baseConfig;
|
2103 |
|
2104 | tmpLocale = loadLocale(name);
|
2105 |
|
2106 | if (tmpLocale != null) {
|
2107 | parentConfig = tmpLocale._config;
|
2108 | }
|
2109 |
|
2110 | config = mergeConfigs(parentConfig, config);
|
2111 | locale = new Locale(config);
|
2112 | locale.parentLocale = locales[name];
|
2113 | locales[name] = locale;
|
2114 |
|
2115 | getSetGlobalLocale(name);
|
2116 | } else {
|
2117 |
|
2118 | if (locales[name] != null) {
|
2119 | if (locales[name].parentLocale != null) {
|
2120 | locales[name] = locales[name].parentLocale;
|
2121 | } else if (locales[name] != null) {
|
2122 | delete locales[name];
|
2123 | }
|
2124 | }
|
2125 | }
|
2126 |
|
2127 | return locales[name];
|
2128 | }
|
2129 |
|
2130 |
|
2131 | function getLocale(key) {
|
2132 | var locale;
|
2133 |
|
2134 | if (key && key._locale && key._locale._abbr) {
|
2135 | key = key._locale._abbr;
|
2136 | }
|
2137 |
|
2138 | if (!key) {
|
2139 | return globalLocale;
|
2140 | }
|
2141 |
|
2142 | if (!isArray(key)) {
|
2143 |
|
2144 | locale = loadLocale(key);
|
2145 |
|
2146 | if (locale) {
|
2147 | return locale;
|
2148 | }
|
2149 |
|
2150 | key = [key];
|
2151 | }
|
2152 |
|
2153 | return chooseLocale(key);
|
2154 | }
|
2155 |
|
2156 | function listLocales() {
|
2157 | return keys(locales);
|
2158 | }
|
2159 |
|
2160 | function checkOverflow(m) {
|
2161 | var overflow;
|
2162 | var a = m._a;
|
2163 |
|
2164 | if (a && getParsingFlags(m).overflow === -2) {
|
2165 | overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1;
|
2166 |
|
2167 | if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
2168 | overflow = DATE;
|
2169 | }
|
2170 |
|
2171 | if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
|
2172 | overflow = WEEK;
|
2173 | }
|
2174 |
|
2175 | if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
|
2176 | overflow = WEEKDAY;
|
2177 | }
|
2178 |
|
2179 | getParsingFlags(m).overflow = overflow;
|
2180 | }
|
2181 |
|
2182 | return m;
|
2183 | }
|
2184 |
|
2185 |
|
2186 | function defaults(a, b, c) {
|
2187 | if (a != null) {
|
2188 | return a;
|
2189 | }
|
2190 |
|
2191 | if (b != null) {
|
2192 | return b;
|
2193 | }
|
2194 |
|
2195 | return c;
|
2196 | }
|
2197 |
|
2198 | function currentDateArray(config) {
|
2199 |
|
2200 | var nowValue = new Date(hooks.now());
|
2201 |
|
2202 | if (config._useUTC) {
|
2203 | return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
|
2204 | }
|
2205 |
|
2206 | return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
|
2207 | }
|
2208 |
|
2209 |
|
2210 |
|
2211 |
|
2212 |
|
2213 | function configFromArray(config) {
|
2214 | var i,
|
2215 | date,
|
2216 | input = [],
|
2217 | currentDate,
|
2218 | expectedWeekday,
|
2219 | yearToUse;
|
2220 |
|
2221 | if (config._d) {
|
2222 | return;
|
2223 | }
|
2224 |
|
2225 | currentDate = currentDateArray(config);
|
2226 |
|
2227 | if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
2228 | dayOfYearFromWeekInfo(config);
|
2229 | }
|
2230 |
|
2231 |
|
2232 | if (config._dayOfYear != null) {
|
2233 | yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
2234 |
|
2235 | if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
|
2236 | getParsingFlags(config)._overflowDayOfYear = true;
|
2237 | }
|
2238 |
|
2239 | date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
2240 | config._a[MONTH] = date.getUTCMonth();
|
2241 | config._a[DATE] = date.getUTCDate();
|
2242 | }
|
2243 |
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 |
|
2249 | for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
2250 | config._a[i] = input[i] = currentDate[i];
|
2251 | }
|
2252 |
|
2253 |
|
2254 | for (; i < 7; i++) {
|
2255 | config._a[i] = input[i] = config._a[i] == null ? i === 2 ? 1 : 0 : config._a[i];
|
2256 | }
|
2257 |
|
2258 |
|
2259 | if (config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0) {
|
2260 | config._nextDay = true;
|
2261 | config._a[HOUR] = 0;
|
2262 | }
|
2263 |
|
2264 | config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
|
2265 | expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
|
2266 |
|
2267 |
|
2268 | if (config._tzm != null) {
|
2269 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
2270 | }
|
2271 |
|
2272 | if (config._nextDay) {
|
2273 | config._a[HOUR] = 24;
|
2274 | }
|
2275 |
|
2276 |
|
2277 | if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
|
2278 | getParsingFlags(config).weekdayMismatch = true;
|
2279 | }
|
2280 | }
|
2281 |
|
2282 | function dayOfYearFromWeekInfo(config) {
|
2283 | var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
|
2284 | w = config._w;
|
2285 |
|
2286 | if (w.GG != null || w.W != null || w.E != null) {
|
2287 | dow = 1;
|
2288 | doy = 4;
|
2289 |
|
2290 |
|
2291 |
|
2292 |
|
2293 | weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
|
2294 | week = defaults(w.W, 1);
|
2295 | weekday = defaults(w.E, 1);
|
2296 |
|
2297 | if (weekday < 1 || weekday > 7) {
|
2298 | weekdayOverflow = true;
|
2299 | }
|
2300 | } else {
|
2301 | dow = config._locale._week.dow;
|
2302 | doy = config._locale._week.doy;
|
2303 | var curWeek = weekOfYear(createLocal(), dow, doy);
|
2304 | weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
|
2305 |
|
2306 | week = defaults(w.w, curWeek.week);
|
2307 |
|
2308 | if (w.d != null) {
|
2309 |
|
2310 | weekday = w.d;
|
2311 |
|
2312 | if (weekday < 0 || weekday > 6) {
|
2313 | weekdayOverflow = true;
|
2314 | }
|
2315 | } else if (w.e != null) {
|
2316 |
|
2317 | weekday = w.e + dow;
|
2318 |
|
2319 | if (w.e < 0 || w.e > 6) {
|
2320 | weekdayOverflow = true;
|
2321 | }
|
2322 | } else {
|
2323 |
|
2324 | weekday = dow;
|
2325 | }
|
2326 | }
|
2327 |
|
2328 | if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
|
2329 | getParsingFlags(config)._overflowWeeks = true;
|
2330 | } else if (weekdayOverflow != null) {
|
2331 | getParsingFlags(config)._overflowWeekday = true;
|
2332 | } else {
|
2333 | temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
|
2334 | config._a[YEAR] = temp.year;
|
2335 | config._dayOfYear = temp.dayOfYear;
|
2336 | }
|
2337 | }
|
2338 |
|
2339 |
|
2340 |
|
2341 | var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
|
2342 | var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
|
2343 | var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
|
2344 | var isoDates = [['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], ['GGGG-[W]WW', /\d{4}-W\d\d/, false], ['YYYY-DDD', /\d{4}-\d{3}/], ['YYYY-MM', /\d{4}-\d\d/, false], ['YYYYYYMMDD', /[+-]\d{10}/], ['YYYYMMDD', /\d{8}/],
|
2345 | ['GGGG[W]WWE', /\d{4}W\d{3}/], ['GGGG[W]WW', /\d{4}W\d{2}/, false], ['YYYYDDD', /\d{7}/]];
|
2346 |
|
2347 | var isoTimes = [['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], ['HH:mm:ss', /\d\d:\d\d:\d\d/], ['HH:mm', /\d\d:\d\d/], ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], ['HHmmss', /\d\d\d\d\d\d/], ['HHmm', /\d\d\d\d/], ['HH', /\d\d/]];
|
2348 | var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
|
2349 |
|
2350 | function configFromISO(config) {
|
2351 | var i,
|
2352 | l,
|
2353 | string = config._i,
|
2354 | match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
|
2355 | allowTime,
|
2356 | dateFormat,
|
2357 | timeFormat,
|
2358 | tzFormat;
|
2359 |
|
2360 | if (match) {
|
2361 | getParsingFlags(config).iso = true;
|
2362 |
|
2363 | for (i = 0, l = isoDates.length; i < l; i++) {
|
2364 | if (isoDates[i][1].exec(match[1])) {
|
2365 | dateFormat = isoDates[i][0];
|
2366 | allowTime = isoDates[i][2] !== false;
|
2367 | break;
|
2368 | }
|
2369 | }
|
2370 |
|
2371 | if (dateFormat == null) {
|
2372 | config._isValid = false;
|
2373 | return;
|
2374 | }
|
2375 |
|
2376 | if (match[3]) {
|
2377 | for (i = 0, l = isoTimes.length; i < l; i++) {
|
2378 | if (isoTimes[i][1].exec(match[3])) {
|
2379 |
|
2380 | timeFormat = (match[2] || ' ') + isoTimes[i][0];
|
2381 | break;
|
2382 | }
|
2383 | }
|
2384 |
|
2385 | if (timeFormat == null) {
|
2386 | config._isValid = false;
|
2387 | return;
|
2388 | }
|
2389 | }
|
2390 |
|
2391 | if (!allowTime && timeFormat != null) {
|
2392 | config._isValid = false;
|
2393 | return;
|
2394 | }
|
2395 |
|
2396 | if (match[4]) {
|
2397 | if (tzRegex.exec(match[4])) {
|
2398 | tzFormat = 'Z';
|
2399 | } else {
|
2400 | config._isValid = false;
|
2401 | return;
|
2402 | }
|
2403 | }
|
2404 |
|
2405 | config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
|
2406 | configFromStringAndFormat(config);
|
2407 | } else {
|
2408 | config._isValid = false;
|
2409 | }
|
2410 | }
|
2411 |
|
2412 |
|
2413 | var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
|
2414 |
|
2415 | function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
2416 | var result = [untruncateYear(yearStr), defaultLocaleMonthsShort.indexOf(monthStr), parseInt(dayStr, 10), parseInt(hourStr, 10), parseInt(minuteStr, 10)];
|
2417 |
|
2418 | if (secondStr) {
|
2419 | result.push(parseInt(secondStr, 10));
|
2420 | }
|
2421 |
|
2422 | return result;
|
2423 | }
|
2424 |
|
2425 | function untruncateYear(yearStr) {
|
2426 | var year = parseInt(yearStr, 10);
|
2427 |
|
2428 | if (year <= 49) {
|
2429 | return 2000 + year;
|
2430 | } else if (year <= 999) {
|
2431 | return 1900 + year;
|
2432 | }
|
2433 |
|
2434 | return year;
|
2435 | }
|
2436 |
|
2437 | function preprocessRFC2822(s) {
|
2438 |
|
2439 | return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
2440 | }
|
2441 |
|
2442 | function checkWeekday(weekdayStr, parsedInput, config) {
|
2443 | if (weekdayStr) {
|
2444 |
|
2445 | var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
|
2446 | weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
|
2447 |
|
2448 | if (weekdayProvided !== weekdayActual) {
|
2449 | getParsingFlags(config).weekdayMismatch = true;
|
2450 | config._isValid = false;
|
2451 | return false;
|
2452 | }
|
2453 | }
|
2454 |
|
2455 | return true;
|
2456 | }
|
2457 |
|
2458 | var obsOffsets = {
|
2459 | UT: 0,
|
2460 | GMT: 0,
|
2461 | EDT: -4 * 60,
|
2462 | EST: -5 * 60,
|
2463 | CDT: -5 * 60,
|
2464 | CST: -6 * 60,
|
2465 | MDT: -6 * 60,
|
2466 | MST: -7 * 60,
|
2467 | PDT: -7 * 60,
|
2468 | PST: -8 * 60
|
2469 | };
|
2470 |
|
2471 | function calculateOffset(obsOffset, militaryOffset, numOffset) {
|
2472 | if (obsOffset) {
|
2473 | return obsOffsets[obsOffset];
|
2474 | } else if (militaryOffset) {
|
2475 |
|
2476 | return 0;
|
2477 | } else {
|
2478 | var hm = parseInt(numOffset, 10);
|
2479 | var m = hm % 100,
|
2480 | h = (hm - m) / 100;
|
2481 | return h * 60 + m;
|
2482 | }
|
2483 | }
|
2484 |
|
2485 |
|
2486 | function configFromRFC2822(config) {
|
2487 | var match = rfc2822.exec(preprocessRFC2822(config._i));
|
2488 |
|
2489 | if (match) {
|
2490 | var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
|
2491 |
|
2492 | if (!checkWeekday(match[1], parsedArray, config)) {
|
2493 | return;
|
2494 | }
|
2495 |
|
2496 | config._a = parsedArray;
|
2497 | config._tzm = calculateOffset(match[8], match[9], match[10]);
|
2498 | config._d = createUTCDate.apply(null, config._a);
|
2499 |
|
2500 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
2501 |
|
2502 | getParsingFlags(config).rfc2822 = true;
|
2503 | } else {
|
2504 | config._isValid = false;
|
2505 | }
|
2506 | }
|
2507 |
|
2508 |
|
2509 | function configFromString(config) {
|
2510 | var matched = aspNetJsonRegex.exec(config._i);
|
2511 |
|
2512 | if (matched !== null) {
|
2513 | config._d = new Date(+matched[1]);
|
2514 | return;
|
2515 | }
|
2516 |
|
2517 | configFromISO(config);
|
2518 |
|
2519 | if (config._isValid === false) {
|
2520 | delete config._isValid;
|
2521 | } else {
|
2522 | return;
|
2523 | }
|
2524 |
|
2525 | configFromRFC2822(config);
|
2526 |
|
2527 | if (config._isValid === false) {
|
2528 | delete config._isValid;
|
2529 | } else {
|
2530 | return;
|
2531 | }
|
2532 |
|
2533 |
|
2534 | hooks.createFromInputFallback(config);
|
2535 | }
|
2536 |
|
2537 | hooks.createFromInputFallback = deprecate('value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 'discouraged and will be removed in an upcoming major release. Please refer to ' + 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', function (config) {
|
2538 | config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
2539 | });
|
2540 |
|
2541 | hooks.ISO_8601 = function () {};
|
2542 |
|
2543 |
|
2544 | hooks.RFC_2822 = function () {};
|
2545 |
|
2546 |
|
2547 | function configFromStringAndFormat(config) {
|
2548 |
|
2549 | if (config._f === hooks.ISO_8601) {
|
2550 | configFromISO(config);
|
2551 | return;
|
2552 | }
|
2553 |
|
2554 | if (config._f === hooks.RFC_2822) {
|
2555 | configFromRFC2822(config);
|
2556 | return;
|
2557 | }
|
2558 |
|
2559 | config._a = [];
|
2560 | getParsingFlags(config).empty = true;
|
2561 |
|
2562 | var string = '' + config._i,
|
2563 | i,
|
2564 | parsedInput,
|
2565 | tokens,
|
2566 | token,
|
2567 | skipped,
|
2568 | stringLength = string.length,
|
2569 | totalParsedInputLength = 0;
|
2570 | tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
|
2571 |
|
2572 | for (i = 0; i < tokens.length; i++) {
|
2573 | token = tokens[i];
|
2574 | parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
|
2575 |
|
2576 |
|
2577 | if (parsedInput) {
|
2578 | skipped = string.substr(0, string.indexOf(parsedInput));
|
2579 |
|
2580 | if (skipped.length > 0) {
|
2581 | getParsingFlags(config).unusedInput.push(skipped);
|
2582 | }
|
2583 |
|
2584 | string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
2585 | totalParsedInputLength += parsedInput.length;
|
2586 | }
|
2587 |
|
2588 |
|
2589 | if (formatTokenFunctions[token]) {
|
2590 | if (parsedInput) {
|
2591 | getParsingFlags(config).empty = false;
|
2592 | } else {
|
2593 | getParsingFlags(config).unusedTokens.push(token);
|
2594 | }
|
2595 |
|
2596 | addTimeToArrayFromToken(token, parsedInput, config);
|
2597 | } else if (config._strict && !parsedInput) {
|
2598 | getParsingFlags(config).unusedTokens.push(token);
|
2599 | }
|
2600 | }
|
2601 |
|
2602 |
|
2603 | getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
2604 |
|
2605 | if (string.length > 0) {
|
2606 | getParsingFlags(config).unusedInput.push(string);
|
2607 | }
|
2608 |
|
2609 |
|
2610 | if (config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0) {
|
2611 | getParsingFlags(config).bigHour = undefined;
|
2612 | }
|
2613 |
|
2614 | getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
2615 | getParsingFlags(config).meridiem = config._meridiem;
|
2616 |
|
2617 | config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
2618 | configFromArray(config);
|
2619 | checkOverflow(config);
|
2620 | }
|
2621 |
|
2622 | function meridiemFixWrap(locale, hour, meridiem) {
|
2623 | var isPm;
|
2624 |
|
2625 | if (meridiem == null) {
|
2626 |
|
2627 | return hour;
|
2628 | }
|
2629 |
|
2630 | if (locale.meridiemHour != null) {
|
2631 | return locale.meridiemHour(hour, meridiem);
|
2632 | } else if (locale.isPM != null) {
|
2633 |
|
2634 | isPm = locale.isPM(meridiem);
|
2635 |
|
2636 | if (isPm && hour < 12) {
|
2637 | hour += 12;
|
2638 | }
|
2639 |
|
2640 | if (!isPm && hour === 12) {
|
2641 | hour = 0;
|
2642 | }
|
2643 |
|
2644 | return hour;
|
2645 | } else {
|
2646 |
|
2647 | return hour;
|
2648 | }
|
2649 | }
|
2650 |
|
2651 |
|
2652 | function configFromStringAndArray(config) {
|
2653 | var tempConfig, bestMoment, scoreToBeat, i, currentScore;
|
2654 |
|
2655 | if (config._f.length === 0) {
|
2656 | getParsingFlags(config).invalidFormat = true;
|
2657 | config._d = new Date(NaN);
|
2658 | return;
|
2659 | }
|
2660 |
|
2661 | for (i = 0; i < config._f.length; i++) {
|
2662 | currentScore = 0;
|
2663 | tempConfig = copyConfig({}, config);
|
2664 |
|
2665 | if (config._useUTC != null) {
|
2666 | tempConfig._useUTC = config._useUTC;
|
2667 | }
|
2668 |
|
2669 | tempConfig._f = config._f[i];
|
2670 | configFromStringAndFormat(tempConfig);
|
2671 |
|
2672 | if (!isValid(tempConfig)) {
|
2673 | continue;
|
2674 | }
|
2675 |
|
2676 |
|
2677 | currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
2678 |
|
2679 | currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
2680 | getParsingFlags(tempConfig).score = currentScore;
|
2681 |
|
2682 | if (scoreToBeat == null || currentScore < scoreToBeat) {
|
2683 | scoreToBeat = currentScore;
|
2684 | bestMoment = tempConfig;
|
2685 | }
|
2686 | }
|
2687 |
|
2688 | extend(config, bestMoment || tempConfig);
|
2689 | }
|
2690 |
|
2691 | function configFromObject(config) {
|
2692 | if (config._d) {
|
2693 | return;
|
2694 | }
|
2695 |
|
2696 | var i = normalizeObjectUnits(config._i);
|
2697 | config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
|
2698 | return obj && parseInt(obj, 10);
|
2699 | });
|
2700 | configFromArray(config);
|
2701 | }
|
2702 |
|
2703 | function createFromConfig(config) {
|
2704 | var res = new Moment(checkOverflow(prepareConfig(config)));
|
2705 |
|
2706 | if (res._nextDay) {
|
2707 |
|
2708 | res.add(1, 'd');
|
2709 | res._nextDay = undefined;
|
2710 | }
|
2711 |
|
2712 | return res;
|
2713 | }
|
2714 |
|
2715 | function prepareConfig(config) {
|
2716 | var input = config._i,
|
2717 | format = config._f;
|
2718 | config._locale = config._locale || getLocale(config._l);
|
2719 |
|
2720 | if (input === null || format === undefined && input === '') {
|
2721 | return createInvalid({
|
2722 | nullInput: true
|
2723 | });
|
2724 | }
|
2725 |
|
2726 | if (typeof input === 'string') {
|
2727 | config._i = input = config._locale.preparse(input);
|
2728 | }
|
2729 |
|
2730 | if (isMoment(input)) {
|
2731 | return new Moment(checkOverflow(input));
|
2732 | } else if (isDate(input)) {
|
2733 | config._d = input;
|
2734 | } else if (isArray(format)) {
|
2735 | configFromStringAndArray(config);
|
2736 | } else if (format) {
|
2737 | configFromStringAndFormat(config);
|
2738 | } else {
|
2739 | configFromInput(config);
|
2740 | }
|
2741 |
|
2742 | if (!isValid(config)) {
|
2743 | config._d = null;
|
2744 | }
|
2745 |
|
2746 | return config;
|
2747 | }
|
2748 |
|
2749 | function configFromInput(config) {
|
2750 | var input = config._i;
|
2751 |
|
2752 | if (isUndefined(input)) {
|
2753 | config._d = new Date(hooks.now());
|
2754 | } else if (isDate(input)) {
|
2755 | config._d = new Date(input.valueOf());
|
2756 | } else if (typeof input === 'string') {
|
2757 | configFromString(config);
|
2758 | } else if (isArray(input)) {
|
2759 | config._a = map(input.slice(0), function (obj) {
|
2760 | return parseInt(obj, 10);
|
2761 | });
|
2762 | configFromArray(config);
|
2763 | } else if (isObject(input)) {
|
2764 | configFromObject(config);
|
2765 | } else if (isNumber(input)) {
|
2766 |
|
2767 | config._d = new Date(input);
|
2768 | } else {
|
2769 | hooks.createFromInputFallback(config);
|
2770 | }
|
2771 | }
|
2772 |
|
2773 | function createLocalOrUTC(input, format, locale, strict, isUTC) {
|
2774 | var c = {};
|
2775 |
|
2776 | if (locale === true || locale === false) {
|
2777 | strict = locale;
|
2778 | locale = undefined;
|
2779 | }
|
2780 |
|
2781 | if (isObject(input) && isObjectEmpty(input) || isArray(input) && input.length === 0) {
|
2782 | input = undefined;
|
2783 | }
|
2784 |
|
2785 |
|
2786 |
|
2787 | c._isAMomentObject = true;
|
2788 | c._useUTC = c._isUTC = isUTC;
|
2789 | c._l = locale;
|
2790 | c._i = input;
|
2791 | c._f = format;
|
2792 | c._strict = strict;
|
2793 | return createFromConfig(c);
|
2794 | }
|
2795 |
|
2796 | function createLocal(input, format, locale, strict) {
|
2797 | return createLocalOrUTC(input, format, locale, strict, false);
|
2798 | }
|
2799 |
|
2800 | var prototypeMin = deprecate('moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
2801 | var other = createLocal.apply(null, arguments);
|
2802 |
|
2803 | if (this.isValid() && other.isValid()) {
|
2804 | return other < this ? this : other;
|
2805 | } else {
|
2806 | return createInvalid();
|
2807 | }
|
2808 | });
|
2809 | var prototypeMax = deprecate('moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
2810 | var other = createLocal.apply(null, arguments);
|
2811 |
|
2812 | if (this.isValid() && other.isValid()) {
|
2813 | return other > this ? this : other;
|
2814 | } else {
|
2815 | return createInvalid();
|
2816 | }
|
2817 | });
|
2818 |
|
2819 |
|
2820 |
|
2821 |
|
2822 |
|
2823 | function pickBy(fn, moments) {
|
2824 | var res, i;
|
2825 |
|
2826 | if (moments.length === 1 && isArray(moments[0])) {
|
2827 | moments = moments[0];
|
2828 | }
|
2829 |
|
2830 | if (!moments.length) {
|
2831 | return createLocal();
|
2832 | }
|
2833 |
|
2834 | res = moments[0];
|
2835 |
|
2836 | for (i = 1; i < moments.length; ++i) {
|
2837 | if (!moments[i].isValid() || moments[i][fn](res)) {
|
2838 | res = moments[i];
|
2839 | }
|
2840 | }
|
2841 |
|
2842 | return res;
|
2843 | }
|
2844 |
|
2845 |
|
2846 | function min() {
|
2847 | var args = [].slice.call(arguments, 0);
|
2848 | return pickBy('isBefore', args);
|
2849 | }
|
2850 |
|
2851 | function max() {
|
2852 | var args = [].slice.call(arguments, 0);
|
2853 | return pickBy('isAfter', args);
|
2854 | }
|
2855 |
|
2856 | var now = function () {
|
2857 | return Date.now ? Date.now() : +new Date();
|
2858 | };
|
2859 |
|
2860 | var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
2861 |
|
2862 | function isDurationValid(m) {
|
2863 | for (var key in m) {
|
2864 | if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
|
2865 | return false;
|
2866 | }
|
2867 | }
|
2868 |
|
2869 | var unitHasDecimal = false;
|
2870 |
|
2871 | for (var i = 0; i < ordering.length; ++i) {
|
2872 | if (m[ordering[i]]) {
|
2873 | if (unitHasDecimal) {
|
2874 | return false;
|
2875 | }
|
2876 |
|
2877 | if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
|
2878 | unitHasDecimal = true;
|
2879 | }
|
2880 | }
|
2881 | }
|
2882 |
|
2883 | return true;
|
2884 | }
|
2885 |
|
2886 | function isValid$1() {
|
2887 | return this._isValid;
|
2888 | }
|
2889 |
|
2890 | function createInvalid$1() {
|
2891 | return createDuration(NaN);
|
2892 | }
|
2893 |
|
2894 | function Duration(duration) {
|
2895 | var normalizedInput = normalizeObjectUnits(duration),
|
2896 | years = normalizedInput.year || 0,
|
2897 | quarters = normalizedInput.quarter || 0,
|
2898 | months = normalizedInput.month || 0,
|
2899 | weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
2900 | days = normalizedInput.day || 0,
|
2901 | hours = normalizedInput.hour || 0,
|
2902 | minutes = normalizedInput.minute || 0,
|
2903 | seconds = normalizedInput.second || 0,
|
2904 | milliseconds = normalizedInput.millisecond || 0;
|
2905 | this._isValid = isDurationValid(normalizedInput);
|
2906 |
|
2907 | this._milliseconds = +milliseconds + seconds * 1e3 +
|
2908 | minutes * 6e4 +
|
2909 | hours * 1000 * 60 * 60;
|
2910 |
|
2911 |
|
2912 |
|
2913 | this._days = +days + weeks * 7;
|
2914 |
|
2915 |
|
2916 |
|
2917 | this._months = +months + quarters * 3 + years * 12;
|
2918 | this._data = {};
|
2919 | this._locale = getLocale();
|
2920 |
|
2921 | this._bubble();
|
2922 | }
|
2923 |
|
2924 | function isDuration(obj) {
|
2925 | return obj instanceof Duration;
|
2926 | }
|
2927 |
|
2928 | function absRound(number) {
|
2929 | if (number < 0) {
|
2930 | return Math.round(-1 * number) * -1;
|
2931 | } else {
|
2932 | return Math.round(number);
|
2933 | }
|
2934 | }
|
2935 |
|
2936 |
|
2937 | function offset(token, separator) {
|
2938 | addFormatToken(token, 0, 0, function () {
|
2939 | var offset = this.utcOffset();
|
2940 | var sign = '+';
|
2941 |
|
2942 | if (offset < 0) {
|
2943 | offset = -offset;
|
2944 | sign = '-';
|
2945 | }
|
2946 |
|
2947 | return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~offset % 60, 2);
|
2948 | });
|
2949 | }
|
2950 |
|
2951 | offset('Z', ':');
|
2952 | offset('ZZ', '');
|
2953 |
|
2954 | addRegexToken('Z', matchShortOffset);
|
2955 | addRegexToken('ZZ', matchShortOffset);
|
2956 | addParseToken(['Z', 'ZZ'], function (input, array, config) {
|
2957 | config._useUTC = true;
|
2958 | config._tzm = offsetFromString(matchShortOffset, input);
|
2959 | });
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 | var chunkOffset = /([\+\-]|\d\d)/gi;
|
2965 |
|
2966 | function offsetFromString(matcher, string) {
|
2967 | var matches = (string || '').match(matcher);
|
2968 |
|
2969 | if (matches === null) {
|
2970 | return null;
|
2971 | }
|
2972 |
|
2973 | var chunk = matches[matches.length - 1] || [];
|
2974 | var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
|
2975 | var minutes = +(parts[1] * 60) + toInt(parts[2]);
|
2976 | return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
|
2977 | }
|
2978 |
|
2979 |
|
2980 | function cloneWithOffset(input, model) {
|
2981 | var res, diff;
|
2982 |
|
2983 | if (model._isUTC) {
|
2984 | res = model.clone();
|
2985 | diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
|
2986 |
|
2987 | res._d.setTime(res._d.valueOf() + diff);
|
2988 |
|
2989 | hooks.updateOffset(res, false);
|
2990 | return res;
|
2991 | } else {
|
2992 | return createLocal(input).local();
|
2993 | }
|
2994 | }
|
2995 |
|
2996 | function getDateOffset(m) {
|
2997 |
|
2998 |
|
2999 | return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
|
3000 | }
|
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 | hooks.updateOffset = function () {};
|
3006 |
|
3007 |
|
3008 |
|
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 |
|
3014 |
|
3015 |
|
3016 |
|
3017 |
|
3018 | function getSetOffset(input, keepLocalTime, keepMinutes) {
|
3019 | var offset = this._offset || 0,
|
3020 | localAdjust;
|
3021 |
|
3022 | if (!this.isValid()) {
|
3023 | return input != null ? this : NaN;
|
3024 | }
|
3025 |
|
3026 | if (input != null) {
|
3027 | if (typeof input === 'string') {
|
3028 | input = offsetFromString(matchShortOffset, input);
|
3029 |
|
3030 | if (input === null) {
|
3031 | return this;
|
3032 | }
|
3033 | } else if (Math.abs(input) < 16 && !keepMinutes) {
|
3034 | input = input * 60;
|
3035 | }
|
3036 |
|
3037 | if (!this._isUTC && keepLocalTime) {
|
3038 | localAdjust = getDateOffset(this);
|
3039 | }
|
3040 |
|
3041 | this._offset = input;
|
3042 | this._isUTC = true;
|
3043 |
|
3044 | if (localAdjust != null) {
|
3045 | this.add(localAdjust, 'm');
|
3046 | }
|
3047 |
|
3048 | if (offset !== input) {
|
3049 | if (!keepLocalTime || this._changeInProgress) {
|
3050 | addSubtract(this, createDuration(input - offset, 'm'), 1, false);
|
3051 | } else if (!this._changeInProgress) {
|
3052 | this._changeInProgress = true;
|
3053 | hooks.updateOffset(this, true);
|
3054 | this._changeInProgress = null;
|
3055 | }
|
3056 | }
|
3057 |
|
3058 | return this;
|
3059 | } else {
|
3060 | return this._isUTC ? offset : getDateOffset(this);
|
3061 | }
|
3062 | }
|
3063 |
|
3064 | function getSetZone(input, keepLocalTime) {
|
3065 | if (input != null) {
|
3066 | if (typeof input !== 'string') {
|
3067 | input = -input;
|
3068 | }
|
3069 |
|
3070 | this.utcOffset(input, keepLocalTime);
|
3071 | return this;
|
3072 | } else {
|
3073 | return -this.utcOffset();
|
3074 | }
|
3075 | }
|
3076 |
|
3077 | function setOffsetToUTC(keepLocalTime) {
|
3078 | return this.utcOffset(0, keepLocalTime);
|
3079 | }
|
3080 |
|
3081 | function setOffsetToLocal(keepLocalTime) {
|
3082 | if (this._isUTC) {
|
3083 | this.utcOffset(0, keepLocalTime);
|
3084 | this._isUTC = false;
|
3085 |
|
3086 | if (keepLocalTime) {
|
3087 | this.subtract(getDateOffset(this), 'm');
|
3088 | }
|
3089 | }
|
3090 |
|
3091 | return this;
|
3092 | }
|
3093 |
|
3094 | function setOffsetToParsedOffset() {
|
3095 | if (this._tzm != null) {
|
3096 | this.utcOffset(this._tzm, false, true);
|
3097 | } else if (typeof this._i === 'string') {
|
3098 | var tZone = offsetFromString(matchOffset, this._i);
|
3099 |
|
3100 | if (tZone != null) {
|
3101 | this.utcOffset(tZone);
|
3102 | } else {
|
3103 | this.utcOffset(0, true);
|
3104 | }
|
3105 | }
|
3106 |
|
3107 | return this;
|
3108 | }
|
3109 |
|
3110 | function hasAlignedHourOffset(input) {
|
3111 | if (!this.isValid()) {
|
3112 | return false;
|
3113 | }
|
3114 |
|
3115 | input = input ? createLocal(input).utcOffset() : 0;
|
3116 | return (this.utcOffset() - input) % 60 === 0;
|
3117 | }
|
3118 |
|
3119 | function isDaylightSavingTime() {
|
3120 | return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset();
|
3121 | }
|
3122 |
|
3123 | function isDaylightSavingTimeShifted() {
|
3124 | if (!isUndefined(this._isDSTShifted)) {
|
3125 | return this._isDSTShifted;
|
3126 | }
|
3127 |
|
3128 | var c = {};
|
3129 | copyConfig(c, this);
|
3130 | c = prepareConfig(c);
|
3131 |
|
3132 | if (c._a) {
|
3133 | var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
|
3134 | this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0;
|
3135 | } else {
|
3136 | this._isDSTShifted = false;
|
3137 | }
|
3138 |
|
3139 | return this._isDSTShifted;
|
3140 | }
|
3141 |
|
3142 | function isLocal() {
|
3143 | return this.isValid() ? !this._isUTC : false;
|
3144 | }
|
3145 |
|
3146 | function isUtcOffset() {
|
3147 | return this.isValid() ? this._isUTC : false;
|
3148 | }
|
3149 |
|
3150 | function isUtc() {
|
3151 | return this.isValid() ? this._isUTC && this._offset === 0 : false;
|
3152 | }
|
3153 |
|
3154 |
|
3155 | var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
|
3156 |
|
3157 |
|
3158 |
|
3159 | var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
|
3160 |
|
3161 | function createDuration(input, key) {
|
3162 | var duration = input,
|
3163 |
|
3164 | match = null,
|
3165 | sign,
|
3166 | ret,
|
3167 | diffRes;
|
3168 |
|
3169 | if (isDuration(input)) {
|
3170 | duration = {
|
3171 | ms: input._milliseconds,
|
3172 | d: input._days,
|
3173 | M: input._months
|
3174 | };
|
3175 | } else if (isNumber(input)) {
|
3176 | duration = {};
|
3177 |
|
3178 | if (key) {
|
3179 | duration[key] = input;
|
3180 | } else {
|
3181 | duration.milliseconds = input;
|
3182 | }
|
3183 | } else if (!!(match = aspNetRegex.exec(input))) {
|
3184 | sign = match[1] === '-' ? -1 : 1;
|
3185 | duration = {
|
3186 | y: 0,
|
3187 | d: toInt(match[DATE]) * sign,
|
3188 | h: toInt(match[HOUR]) * sign,
|
3189 | m: toInt(match[MINUTE]) * sign,
|
3190 | s: toInt(match[SECOND]) * sign,
|
3191 | ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign
|
3192 |
|
3193 | };
|
3194 | } else if (!!(match = isoRegex.exec(input))) {
|
3195 | sign = match[1] === '-' ? -1 : 1;
|
3196 | duration = {
|
3197 | y: parseIso(match[2], sign),
|
3198 | M: parseIso(match[3], sign),
|
3199 | w: parseIso(match[4], sign),
|
3200 | d: parseIso(match[5], sign),
|
3201 | h: parseIso(match[6], sign),
|
3202 | m: parseIso(match[7], sign),
|
3203 | s: parseIso(match[8], sign)
|
3204 | };
|
3205 | } else if (duration == null) {
|
3206 |
|
3207 | duration = {};
|
3208 | } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
|
3209 | diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
|
3210 | duration = {};
|
3211 | duration.ms = diffRes.milliseconds;
|
3212 | duration.M = diffRes.months;
|
3213 | }
|
3214 |
|
3215 | ret = new Duration(duration);
|
3216 |
|
3217 | if (isDuration(input) && hasOwnProp(input, '_locale')) {
|
3218 | ret._locale = input._locale;
|
3219 | }
|
3220 |
|
3221 | return ret;
|
3222 | }
|
3223 |
|
3224 | createDuration.fn = Duration.prototype;
|
3225 | createDuration.invalid = createInvalid$1;
|
3226 |
|
3227 | function parseIso(inp, sign) {
|
3228 |
|
3229 |
|
3230 |
|
3231 | var res = inp && parseFloat(inp.replace(',', '.'));
|
3232 |
|
3233 | return (isNaN(res) ? 0 : res) * sign;
|
3234 | }
|
3235 |
|
3236 | function positiveMomentsDifference(base, other) {
|
3237 | var res = {};
|
3238 | res.months = other.month() - base.month() + (other.year() - base.year()) * 12;
|
3239 |
|
3240 | if (base.clone().add(res.months, 'M').isAfter(other)) {
|
3241 | --res.months;
|
3242 | }
|
3243 |
|
3244 | res.milliseconds = +other - +base.clone().add(res.months, 'M');
|
3245 | return res;
|
3246 | }
|
3247 |
|
3248 | function momentsDifference(base, other) {
|
3249 | var res;
|
3250 |
|
3251 | if (!(base.isValid() && other.isValid())) {
|
3252 | return {
|
3253 | milliseconds: 0,
|
3254 | months: 0
|
3255 | };
|
3256 | }
|
3257 |
|
3258 | other = cloneWithOffset(other, base);
|
3259 |
|
3260 | if (base.isBefore(other)) {
|
3261 | res = positiveMomentsDifference(base, other);
|
3262 | } else {
|
3263 | res = positiveMomentsDifference(other, base);
|
3264 | res.milliseconds = -res.milliseconds;
|
3265 | res.months = -res.months;
|
3266 | }
|
3267 |
|
3268 | return res;
|
3269 | }
|
3270 |
|
3271 |
|
3272 | function createAdder(direction, name) {
|
3273 | return function (val, period) {
|
3274 | var dur, tmp;
|
3275 |
|
3276 | if (period !== null && !isNaN(+period)) {
|
3277 | deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
|
3278 | tmp = val;
|
3279 | val = period;
|
3280 | period = tmp;
|
3281 | }
|
3282 |
|
3283 | val = typeof val === 'string' ? +val : val;
|
3284 | dur = createDuration(val, period);
|
3285 | addSubtract(this, dur, direction);
|
3286 | return this;
|
3287 | };
|
3288 | }
|
3289 |
|
3290 | function addSubtract(mom, duration, isAdding, updateOffset) {
|
3291 | var milliseconds = duration._milliseconds,
|
3292 | days = absRound(duration._days),
|
3293 | months = absRound(duration._months);
|
3294 |
|
3295 | if (!mom.isValid()) {
|
3296 |
|
3297 | return;
|
3298 | }
|
3299 |
|
3300 | updateOffset = updateOffset == null ? true : updateOffset;
|
3301 |
|
3302 | if (months) {
|
3303 | setMonth(mom, get(mom, 'Month') + months * isAdding);
|
3304 | }
|
3305 |
|
3306 | if (days) {
|
3307 | set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
|
3308 | }
|
3309 |
|
3310 | if (milliseconds) {
|
3311 | mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
3312 | }
|
3313 |
|
3314 | if (updateOffset) {
|
3315 | hooks.updateOffset(mom, days || months);
|
3316 | }
|
3317 | }
|
3318 |
|
3319 | var add = createAdder(1, 'add');
|
3320 | var subtract = createAdder(-1, 'subtract');
|
3321 |
|
3322 | function getCalendarFormat(myMoment, now) {
|
3323 | var diff = myMoment.diff(now, 'days', true);
|
3324 | return diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse';
|
3325 | }
|
3326 |
|
3327 | function calendar$1(time, formats) {
|
3328 |
|
3329 |
|
3330 | var now = time || createLocal(),
|
3331 | sod = cloneWithOffset(now, this).startOf('day'),
|
3332 | format = hooks.calendarFormat(this, sod) || 'sameElse';
|
3333 | var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
|
3334 | return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
|
3335 | }
|
3336 |
|
3337 | function clone() {
|
3338 | return new Moment(this);
|
3339 | }
|
3340 |
|
3341 | function isAfter(input, units) {
|
3342 | var localInput = isMoment(input) ? input : createLocal(input);
|
3343 |
|
3344 | if (!(this.isValid() && localInput.isValid())) {
|
3345 | return false;
|
3346 | }
|
3347 |
|
3348 | units = normalizeUnits(units) || 'millisecond';
|
3349 |
|
3350 | if (units === 'millisecond') {
|
3351 | return this.valueOf() > localInput.valueOf();
|
3352 | } else {
|
3353 | return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
3354 | }
|
3355 | }
|
3356 |
|
3357 | function isBefore(input, units) {
|
3358 | var localInput = isMoment(input) ? input : createLocal(input);
|
3359 |
|
3360 | if (!(this.isValid() && localInput.isValid())) {
|
3361 | return false;
|
3362 | }
|
3363 |
|
3364 | units = normalizeUnits(units) || 'millisecond';
|
3365 |
|
3366 | if (units === 'millisecond') {
|
3367 | return this.valueOf() < localInput.valueOf();
|
3368 | } else {
|
3369 | return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
3370 | }
|
3371 | }
|
3372 |
|
3373 | function isBetween(from, to, units, inclusivity) {
|
3374 | var localFrom = isMoment(from) ? from : createLocal(from),
|
3375 | localTo = isMoment(to) ? to : createLocal(to);
|
3376 |
|
3377 | if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
3378 | return false;
|
3379 | }
|
3380 |
|
3381 | inclusivity = inclusivity || '()';
|
3382 | return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
3383 | }
|
3384 |
|
3385 | function isSame(input, units) {
|
3386 | var localInput = isMoment(input) ? input : createLocal(input),
|
3387 | inputMs;
|
3388 |
|
3389 | if (!(this.isValid() && localInput.isValid())) {
|
3390 | return false;
|
3391 | }
|
3392 |
|
3393 | units = normalizeUnits(units) || 'millisecond';
|
3394 |
|
3395 | if (units === 'millisecond') {
|
3396 | return this.valueOf() === localInput.valueOf();
|
3397 | } else {
|
3398 | inputMs = localInput.valueOf();
|
3399 | return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
3400 | }
|
3401 | }
|
3402 |
|
3403 | function isSameOrAfter(input, units) {
|
3404 | return this.isSame(input, units) || this.isAfter(input, units);
|
3405 | }
|
3406 |
|
3407 | function isSameOrBefore(input, units) {
|
3408 | return this.isSame(input, units) || this.isBefore(input, units);
|
3409 | }
|
3410 |
|
3411 | function diff(input, units, asFloat) {
|
3412 | var that, zoneDelta, output;
|
3413 |
|
3414 | if (!this.isValid()) {
|
3415 | return NaN;
|
3416 | }
|
3417 |
|
3418 | that = cloneWithOffset(input, this);
|
3419 |
|
3420 | if (!that.isValid()) {
|
3421 | return NaN;
|
3422 | }
|
3423 |
|
3424 | zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
|
3425 | units = normalizeUnits(units);
|
3426 |
|
3427 | switch (units) {
|
3428 | case 'year':
|
3429 | output = monthDiff(this, that) / 12;
|
3430 | break;
|
3431 |
|
3432 | case 'month':
|
3433 | output = monthDiff(this, that);
|
3434 | break;
|
3435 |
|
3436 | case 'quarter':
|
3437 | output = monthDiff(this, that) / 3;
|
3438 | break;
|
3439 |
|
3440 | case 'second':
|
3441 | output = (this - that) / 1e3;
|
3442 | break;
|
3443 |
|
3444 |
|
3445 | case 'minute':
|
3446 | output = (this - that) / 6e4;
|
3447 | break;
|
3448 |
|
3449 |
|
3450 | case 'hour':
|
3451 | output = (this - that) / 36e5;
|
3452 | break;
|
3453 |
|
3454 |
|
3455 | case 'day':
|
3456 | output = (this - that - zoneDelta) / 864e5;
|
3457 | break;
|
3458 |
|
3459 |
|
3460 | case 'week':
|
3461 | output = (this - that - zoneDelta) / 6048e5;
|
3462 | break;
|
3463 |
|
3464 |
|
3465 | default:
|
3466 | output = this - that;
|
3467 | }
|
3468 |
|
3469 | return asFloat ? output : absFloor(output);
|
3470 | }
|
3471 |
|
3472 | function monthDiff(a, b) {
|
3473 |
|
3474 | var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
|
3475 |
|
3476 | anchor = a.clone().add(wholeMonthDiff, 'months'),
|
3477 | anchor2,
|
3478 | adjust;
|
3479 |
|
3480 | if (b - anchor < 0) {
|
3481 | anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
|
3482 |
|
3483 | adjust = (b - anchor) / (anchor - anchor2);
|
3484 | } else {
|
3485 | anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
|
3486 |
|
3487 | adjust = (b - anchor) / (anchor2 - anchor);
|
3488 | }
|
3489 |
|
3490 |
|
3491 | return -(wholeMonthDiff + adjust) || 0;
|
3492 | }
|
3493 |
|
3494 | hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
3495 | hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
3496 |
|
3497 | function toString() {
|
3498 | return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
3499 | }
|
3500 |
|
3501 | function toISOString(keepOffset) {
|
3502 | if (!this.isValid()) {
|
3503 | return null;
|
3504 | }
|
3505 |
|
3506 | var utc = keepOffset !== true;
|
3507 | var m = utc ? this.clone().utc() : this;
|
3508 |
|
3509 | if (m.year() < 0 || m.year() > 9999) {
|
3510 | return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
3511 | }
|
3512 |
|
3513 | if (isFunction(Date.prototype.toISOString)) {
|
3514 |
|
3515 | if (utc) {
|
3516 | return this.toDate().toISOString();
|
3517 | } else {
|
3518 | return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
|
3519 | }
|
3520 | }
|
3521 |
|
3522 | return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
3523 | }
|
3524 | |
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 |
|
3532 | function inspect() {
|
3533 | if (!this.isValid()) {
|
3534 | return 'moment.invalid(/* ' + this._i + ' */)';
|
3535 | }
|
3536 |
|
3537 | var func = 'moment';
|
3538 | var zone = '';
|
3539 |
|
3540 | if (!this.isLocal()) {
|
3541 | func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
|
3542 | zone = 'Z';
|
3543 | }
|
3544 |
|
3545 | var prefix = '[' + func + '("]';
|
3546 | var year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
|
3547 | var datetime = '-MM-DD[T]HH:mm:ss.SSS';
|
3548 | var suffix = zone + '[")]';
|
3549 | return this.format(prefix + year + datetime + suffix);
|
3550 | }
|
3551 |
|
3552 | function format(inputString) {
|
3553 | if (!inputString) {
|
3554 | inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
|
3555 | }
|
3556 |
|
3557 | var output = formatMoment(this, inputString);
|
3558 | return this.localeData().postformat(output);
|
3559 | }
|
3560 |
|
3561 | function from(time, withoutSuffix) {
|
3562 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
3563 | return createDuration({
|
3564 | to: this,
|
3565 | from: time
|
3566 | }).locale(this.locale()).humanize(!withoutSuffix);
|
3567 | } else {
|
3568 | return this.localeData().invalidDate();
|
3569 | }
|
3570 | }
|
3571 |
|
3572 | function fromNow(withoutSuffix) {
|
3573 | return this.from(createLocal(), withoutSuffix);
|
3574 | }
|
3575 |
|
3576 | function to(time, withoutSuffix) {
|
3577 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
3578 | return createDuration({
|
3579 | from: this,
|
3580 | to: time
|
3581 | }).locale(this.locale()).humanize(!withoutSuffix);
|
3582 | } else {
|
3583 | return this.localeData().invalidDate();
|
3584 | }
|
3585 | }
|
3586 |
|
3587 | function toNow(withoutSuffix) {
|
3588 | return this.to(createLocal(), withoutSuffix);
|
3589 | }
|
3590 |
|
3591 |
|
3592 |
|
3593 |
|
3594 | function locale(key) {
|
3595 | var newLocaleData;
|
3596 |
|
3597 | if (key === undefined) {
|
3598 | return this._locale._abbr;
|
3599 | } else {
|
3600 | newLocaleData = getLocale(key);
|
3601 |
|
3602 | if (newLocaleData != null) {
|
3603 | this._locale = newLocaleData;
|
3604 | }
|
3605 |
|
3606 | return this;
|
3607 | }
|
3608 | }
|
3609 |
|
3610 | var lang = deprecate('moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', function (key) {
|
3611 | if (key === undefined) {
|
3612 | return this.localeData();
|
3613 | } else {
|
3614 | return this.locale(key);
|
3615 | }
|
3616 | });
|
3617 |
|
3618 | function localeData() {
|
3619 | return this._locale;
|
3620 | }
|
3621 |
|
3622 | var MS_PER_SECOND = 1000;
|
3623 | var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
3624 | var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
3625 | var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
3626 |
|
3627 | function mod$1(dividend, divisor) {
|
3628 | return (dividend % divisor + divisor) % divisor;
|
3629 | }
|
3630 |
|
3631 | function localStartOfDate(y, m, d) {
|
3632 |
|
3633 | if (y < 100 && y >= 0) {
|
3634 |
|
3635 | return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
3636 | } else {
|
3637 | return new Date(y, m, d).valueOf();
|
3638 | }
|
3639 | }
|
3640 |
|
3641 | function utcStartOfDate(y, m, d) {
|
3642 |
|
3643 | if (y < 100 && y >= 0) {
|
3644 |
|
3645 | return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
3646 | } else {
|
3647 | return Date.UTC(y, m, d);
|
3648 | }
|
3649 | }
|
3650 |
|
3651 | function startOf(units) {
|
3652 | var time;
|
3653 | units = normalizeUnits(units);
|
3654 |
|
3655 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
3656 | return this;
|
3657 | }
|
3658 |
|
3659 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
3660 |
|
3661 | switch (units) {
|
3662 | case 'year':
|
3663 | time = startOfDate(this.year(), 0, 1);
|
3664 | break;
|
3665 |
|
3666 | case 'quarter':
|
3667 | time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
3668 | break;
|
3669 |
|
3670 | case 'month':
|
3671 | time = startOfDate(this.year(), this.month(), 1);
|
3672 | break;
|
3673 |
|
3674 | case 'week':
|
3675 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
3676 | break;
|
3677 |
|
3678 | case 'isoWeek':
|
3679 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
3680 | break;
|
3681 |
|
3682 | case 'day':
|
3683 | case 'date':
|
3684 | time = startOfDate(this.year(), this.month(), this.date());
|
3685 | break;
|
3686 |
|
3687 | case 'hour':
|
3688 | time = this._d.valueOf();
|
3689 | time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
3690 | break;
|
3691 |
|
3692 | case 'minute':
|
3693 | time = this._d.valueOf();
|
3694 | time -= mod$1(time, MS_PER_MINUTE);
|
3695 | break;
|
3696 |
|
3697 | case 'second':
|
3698 | time = this._d.valueOf();
|
3699 | time -= mod$1(time, MS_PER_SECOND);
|
3700 | break;
|
3701 | }
|
3702 |
|
3703 | this._d.setTime(time);
|
3704 |
|
3705 | hooks.updateOffset(this, true);
|
3706 | return this;
|
3707 | }
|
3708 |
|
3709 | function endOf(units) {
|
3710 | var time;
|
3711 | units = normalizeUnits(units);
|
3712 |
|
3713 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
3714 | return this;
|
3715 | }
|
3716 |
|
3717 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
3718 |
|
3719 | switch (units) {
|
3720 | case 'year':
|
3721 | time = startOfDate(this.year() + 1, 0, 1) - 1;
|
3722 | break;
|
3723 |
|
3724 | case 'quarter':
|
3725 | time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
3726 | break;
|
3727 |
|
3728 | case 'month':
|
3729 | time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
3730 | break;
|
3731 |
|
3732 | case 'week':
|
3733 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
3734 | break;
|
3735 |
|
3736 | case 'isoWeek':
|
3737 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
3738 | break;
|
3739 |
|
3740 | case 'day':
|
3741 | case 'date':
|
3742 | time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
3743 | break;
|
3744 |
|
3745 | case 'hour':
|
3746 | time = this._d.valueOf();
|
3747 | time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
3748 | break;
|
3749 |
|
3750 | case 'minute':
|
3751 | time = this._d.valueOf();
|
3752 | time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
3753 | break;
|
3754 |
|
3755 | case 'second':
|
3756 | time = this._d.valueOf();
|
3757 | time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
3758 | break;
|
3759 | }
|
3760 |
|
3761 | this._d.setTime(time);
|
3762 |
|
3763 | hooks.updateOffset(this, true);
|
3764 | return this;
|
3765 | }
|
3766 |
|
3767 | function valueOf() {
|
3768 | return this._d.valueOf() - (this._offset || 0) * 60000;
|
3769 | }
|
3770 |
|
3771 | function unix() {
|
3772 | return Math.floor(this.valueOf() / 1000);
|
3773 | }
|
3774 |
|
3775 | function toDate() {
|
3776 | return new Date(this.valueOf());
|
3777 | }
|
3778 |
|
3779 | function toArray() {
|
3780 | var m = this;
|
3781 | return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
|
3782 | }
|
3783 |
|
3784 | function toObject() {
|
3785 | var m = this;
|
3786 | return {
|
3787 | years: m.year(),
|
3788 | months: m.month(),
|
3789 | date: m.date(),
|
3790 | hours: m.hours(),
|
3791 | minutes: m.minutes(),
|
3792 | seconds: m.seconds(),
|
3793 | milliseconds: m.milliseconds()
|
3794 | };
|
3795 | }
|
3796 |
|
3797 | function toJSON() {
|
3798 |
|
3799 | return this.isValid() ? this.toISOString() : null;
|
3800 | }
|
3801 |
|
3802 | function isValid$2() {
|
3803 | return isValid(this);
|
3804 | }
|
3805 |
|
3806 | function parsingFlags() {
|
3807 | return extend({}, getParsingFlags(this));
|
3808 | }
|
3809 |
|
3810 | function invalidAt() {
|
3811 | return getParsingFlags(this).overflow;
|
3812 | }
|
3813 |
|
3814 | function creationData() {
|
3815 | return {
|
3816 | input: this._i,
|
3817 | format: this._f,
|
3818 | locale: this._locale,
|
3819 | isUTC: this._isUTC,
|
3820 | strict: this._strict
|
3821 | };
|
3822 | }
|
3823 |
|
3824 |
|
3825 | addFormatToken(0, ['gg', 2], 0, function () {
|
3826 | return this.weekYear() % 100;
|
3827 | });
|
3828 | addFormatToken(0, ['GG', 2], 0, function () {
|
3829 | return this.isoWeekYear() % 100;
|
3830 | });
|
3831 |
|
3832 | function addWeekYearFormatToken(token, getter) {
|
3833 | addFormatToken(0, [token, token.length], 0, getter);
|
3834 | }
|
3835 |
|
3836 | addWeekYearFormatToken('gggg', 'weekYear');
|
3837 | addWeekYearFormatToken('ggggg', 'weekYear');
|
3838 | addWeekYearFormatToken('GGGG', 'isoWeekYear');
|
3839 | addWeekYearFormatToken('GGGGG', 'isoWeekYear');
|
3840 |
|
3841 | addUnitAlias('weekYear', 'gg');
|
3842 | addUnitAlias('isoWeekYear', 'GG');
|
3843 |
|
3844 | addUnitPriority('weekYear', 1);
|
3845 | addUnitPriority('isoWeekYear', 1);
|
3846 |
|
3847 | addRegexToken('G', matchSigned);
|
3848 | addRegexToken('g', matchSigned);
|
3849 | addRegexToken('GG', match1to2, match2);
|
3850 | addRegexToken('gg', match1to2, match2);
|
3851 | addRegexToken('GGGG', match1to4, match4);
|
3852 | addRegexToken('gggg', match1to4, match4);
|
3853 | addRegexToken('GGGGG', match1to6, match6);
|
3854 | addRegexToken('ggggg', match1to6, match6);
|
3855 | addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
|
3856 | week[token.substr(0, 2)] = toInt(input);
|
3857 | });
|
3858 | addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
|
3859 | week[token] = hooks.parseTwoDigitYear(input);
|
3860 | });
|
3861 |
|
3862 | function getSetWeekYear(input) {
|
3863 | return getSetWeekYearHelper.call(this, input, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy);
|
3864 | }
|
3865 |
|
3866 | function getSetISOWeekYear(input) {
|
3867 | return getSetWeekYearHelper.call(this, input, this.isoWeek(), this.isoWeekday(), 1, 4);
|
3868 | }
|
3869 |
|
3870 | function getISOWeeksInYear() {
|
3871 | return weeksInYear(this.year(), 1, 4);
|
3872 | }
|
3873 |
|
3874 | function getWeeksInYear() {
|
3875 | var weekInfo = this.localeData()._week;
|
3876 |
|
3877 | return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
3878 | }
|
3879 |
|
3880 | function getSetWeekYearHelper(input, week, weekday, dow, doy) {
|
3881 | var weeksTarget;
|
3882 |
|
3883 | if (input == null) {
|
3884 | return weekOfYear(this, dow, doy).year;
|
3885 | } else {
|
3886 | weeksTarget = weeksInYear(input, dow, doy);
|
3887 |
|
3888 | if (week > weeksTarget) {
|
3889 | week = weeksTarget;
|
3890 | }
|
3891 |
|
3892 | return setWeekAll.call(this, input, week, weekday, dow, doy);
|
3893 | }
|
3894 | }
|
3895 |
|
3896 | function setWeekAll(weekYear, week, weekday, dow, doy) {
|
3897 | var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
|
3898 | date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
|
3899 | this.year(date.getUTCFullYear());
|
3900 | this.month(date.getUTCMonth());
|
3901 | this.date(date.getUTCDate());
|
3902 | return this;
|
3903 | }
|
3904 |
|
3905 |
|
3906 | addFormatToken('Q', 0, 'Qo', 'quarter');
|
3907 |
|
3908 | addUnitAlias('quarter', 'Q');
|
3909 |
|
3910 | addUnitPriority('quarter', 7);
|
3911 |
|
3912 | addRegexToken('Q', match1);
|
3913 | addParseToken('Q', function (input, array) {
|
3914 | array[MONTH] = (toInt(input) - 1) * 3;
|
3915 | });
|
3916 |
|
3917 | function getSetQuarter(input) {
|
3918 | return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
3919 | }
|
3920 |
|
3921 |
|
3922 | addFormatToken('D', ['DD', 2], 'Do', 'date');
|
3923 |
|
3924 | addUnitAlias('date', 'D');
|
3925 |
|
3926 | addUnitPriority('date', 9);
|
3927 |
|
3928 | addRegexToken('D', match1to2);
|
3929 | addRegexToken('DD', match1to2, match2);
|
3930 | addRegexToken('Do', function (isStrict, locale) {
|
3931 |
|
3932 | return isStrict ? locale._dayOfMonthOrdinalParse || locale._ordinalParse : locale._dayOfMonthOrdinalParseLenient;
|
3933 | });
|
3934 | addParseToken(['D', 'DD'], DATE);
|
3935 | addParseToken('Do', function (input, array) {
|
3936 | array[DATE] = toInt(input.match(match1to2)[0]);
|
3937 | });
|
3938 |
|
3939 | var getSetDayOfMonth = makeGetSet('Date', true);
|
3940 |
|
3941 | addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
3942 |
|
3943 | addUnitAlias('dayOfYear', 'DDD');
|
3944 |
|
3945 | addUnitPriority('dayOfYear', 4);
|
3946 |
|
3947 | addRegexToken('DDD', match1to3);
|
3948 | addRegexToken('DDDD', match3);
|
3949 | addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
3950 | config._dayOfYear = toInt(input);
|
3951 | });
|
3952 |
|
3953 |
|
3954 | function getSetDayOfYear(input) {
|
3955 | var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
3956 | return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
|
3957 | }
|
3958 |
|
3959 |
|
3960 | addFormatToken('m', ['mm', 2], 0, 'minute');
|
3961 |
|
3962 | addUnitAlias('minute', 'm');
|
3963 |
|
3964 | addUnitPriority('minute', 14);
|
3965 |
|
3966 | addRegexToken('m', match1to2);
|
3967 | addRegexToken('mm', match1to2, match2);
|
3968 | addParseToken(['m', 'mm'], MINUTE);
|
3969 |
|
3970 | var getSetMinute = makeGetSet('Minutes', false);
|
3971 |
|
3972 | addFormatToken('s', ['ss', 2], 0, 'second');
|
3973 |
|
3974 | addUnitAlias('second', 's');
|
3975 |
|
3976 | addUnitPriority('second', 15);
|
3977 |
|
3978 | addRegexToken('s', match1to2);
|
3979 | addRegexToken('ss', match1to2, match2);
|
3980 | addParseToken(['s', 'ss'], SECOND);
|
3981 |
|
3982 | var getSetSecond = makeGetSet('Seconds', false);
|
3983 |
|
3984 | addFormatToken('S', 0, 0, function () {
|
3985 | return ~~(this.millisecond() / 100);
|
3986 | });
|
3987 | addFormatToken(0, ['SS', 2], 0, function () {
|
3988 | return ~~(this.millisecond() / 10);
|
3989 | });
|
3990 | addFormatToken(0, ['SSS', 3], 0, 'millisecond');
|
3991 | addFormatToken(0, ['SSSS', 4], 0, function () {
|
3992 | return this.millisecond() * 10;
|
3993 | });
|
3994 | addFormatToken(0, ['SSSSS', 5], 0, function () {
|
3995 | return this.millisecond() * 100;
|
3996 | });
|
3997 | addFormatToken(0, ['SSSSSS', 6], 0, function () {
|
3998 | return this.millisecond() * 1000;
|
3999 | });
|
4000 | addFormatToken(0, ['SSSSSSS', 7], 0, function () {
|
4001 | return this.millisecond() * 10000;
|
4002 | });
|
4003 | addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
|
4004 | return this.millisecond() * 100000;
|
4005 | });
|
4006 | addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
|
4007 | return this.millisecond() * 1000000;
|
4008 | });
|
4009 |
|
4010 | addUnitAlias('millisecond', 'ms');
|
4011 |
|
4012 | addUnitPriority('millisecond', 16);
|
4013 |
|
4014 | addRegexToken('S', match1to3, match1);
|
4015 | addRegexToken('SS', match1to3, match2);
|
4016 | addRegexToken('SSS', match1to3, match3);
|
4017 | var token;
|
4018 |
|
4019 | for (token = 'SSSS'; token.length <= 9; token += 'S') {
|
4020 | addRegexToken(token, matchUnsigned);
|
4021 | }
|
4022 |
|
4023 | function parseMs(input, array) {
|
4024 | array[MILLISECOND] = toInt(('0.' + input) * 1000);
|
4025 | }
|
4026 |
|
4027 | for (token = 'S'; token.length <= 9; token += 'S') {
|
4028 | addParseToken(token, parseMs);
|
4029 | }
|
4030 |
|
4031 |
|
4032 | var getSetMillisecond = makeGetSet('Milliseconds', false);
|
4033 |
|
4034 | addFormatToken('z', 0, 0, 'zoneAbbr');
|
4035 | addFormatToken('zz', 0, 0, 'zoneName');
|
4036 |
|
4037 | function getZoneAbbr() {
|
4038 | return this._isUTC ? 'UTC' : '';
|
4039 | }
|
4040 |
|
4041 | function getZoneName() {
|
4042 | return this._isUTC ? 'Coordinated Universal Time' : '';
|
4043 | }
|
4044 |
|
4045 | var proto = Moment.prototype;
|
4046 | proto.add = add;
|
4047 | proto.calendar = calendar$1;
|
4048 | proto.clone = clone;
|
4049 | proto.diff = diff;
|
4050 | proto.endOf = endOf;
|
4051 | proto.format = format;
|
4052 | proto.from = from;
|
4053 | proto.fromNow = fromNow;
|
4054 | proto.to = to;
|
4055 | proto.toNow = toNow;
|
4056 | proto.get = stringGet;
|
4057 | proto.invalidAt = invalidAt;
|
4058 | proto.isAfter = isAfter;
|
4059 | proto.isBefore = isBefore;
|
4060 | proto.isBetween = isBetween;
|
4061 | proto.isSame = isSame;
|
4062 | proto.isSameOrAfter = isSameOrAfter;
|
4063 | proto.isSameOrBefore = isSameOrBefore;
|
4064 | proto.isValid = isValid$2;
|
4065 | proto.lang = lang;
|
4066 | proto.locale = locale;
|
4067 | proto.localeData = localeData;
|
4068 | proto.max = prototypeMax;
|
4069 | proto.min = prototypeMin;
|
4070 | proto.parsingFlags = parsingFlags;
|
4071 | proto.set = stringSet;
|
4072 | proto.startOf = startOf;
|
4073 | proto.subtract = subtract;
|
4074 | proto.toArray = toArray;
|
4075 | proto.toObject = toObject;
|
4076 | proto.toDate = toDate;
|
4077 | proto.toISOString = toISOString;
|
4078 | proto.inspect = inspect;
|
4079 | proto.toJSON = toJSON;
|
4080 | proto.toString = toString;
|
4081 | proto.unix = unix;
|
4082 | proto.valueOf = valueOf;
|
4083 | proto.creationData = creationData;
|
4084 | proto.year = getSetYear;
|
4085 | proto.isLeapYear = getIsLeapYear;
|
4086 | proto.weekYear = getSetWeekYear;
|
4087 | proto.isoWeekYear = getSetISOWeekYear;
|
4088 | proto.quarter = proto.quarters = getSetQuarter;
|
4089 | proto.month = getSetMonth;
|
4090 | proto.daysInMonth = getDaysInMonth;
|
4091 | proto.week = proto.weeks = getSetWeek;
|
4092 | proto.isoWeek = proto.isoWeeks = getSetISOWeek;
|
4093 | proto.weeksInYear = getWeeksInYear;
|
4094 | proto.isoWeeksInYear = getISOWeeksInYear;
|
4095 | proto.date = getSetDayOfMonth;
|
4096 | proto.day = proto.days = getSetDayOfWeek;
|
4097 | proto.weekday = getSetLocaleDayOfWeek;
|
4098 | proto.isoWeekday = getSetISODayOfWeek;
|
4099 | proto.dayOfYear = getSetDayOfYear;
|
4100 | proto.hour = proto.hours = getSetHour;
|
4101 | proto.minute = proto.minutes = getSetMinute;
|
4102 | proto.second = proto.seconds = getSetSecond;
|
4103 | proto.millisecond = proto.milliseconds = getSetMillisecond;
|
4104 | proto.utcOffset = getSetOffset;
|
4105 | proto.utc = setOffsetToUTC;
|
4106 | proto.local = setOffsetToLocal;
|
4107 | proto.parseZone = setOffsetToParsedOffset;
|
4108 | proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
4109 | proto.isDST = isDaylightSavingTime;
|
4110 | proto.isLocal = isLocal;
|
4111 | proto.isUtcOffset = isUtcOffset;
|
4112 | proto.isUtc = isUtc;
|
4113 | proto.isUTC = isUtc;
|
4114 | proto.zoneAbbr = getZoneAbbr;
|
4115 | proto.zoneName = getZoneName;
|
4116 | proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
4117 | proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
4118 | proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
4119 | proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
|
4120 | proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
|
4121 |
|
4122 | function createUnix(input) {
|
4123 | return createLocal(input * 1000);
|
4124 | }
|
4125 |
|
4126 | function createInZone() {
|
4127 | return createLocal.apply(null, arguments).parseZone();
|
4128 | }
|
4129 |
|
4130 | function preParsePostFormat(string) {
|
4131 | return string;
|
4132 | }
|
4133 |
|
4134 | var proto$1 = Locale.prototype;
|
4135 | proto$1.calendar = calendar;
|
4136 | proto$1.longDateFormat = longDateFormat;
|
4137 | proto$1.invalidDate = invalidDate;
|
4138 | proto$1.ordinal = ordinal;
|
4139 | proto$1.preparse = preParsePostFormat;
|
4140 | proto$1.postformat = preParsePostFormat;
|
4141 | proto$1.relativeTime = relativeTime;
|
4142 | proto$1.pastFuture = pastFuture;
|
4143 | proto$1.set = set;
|
4144 | proto$1.months = localeMonths;
|
4145 | proto$1.monthsShort = localeMonthsShort;
|
4146 | proto$1.monthsParse = localeMonthsParse;
|
4147 | proto$1.monthsRegex = monthsRegex;
|
4148 | proto$1.monthsShortRegex = monthsShortRegex;
|
4149 | proto$1.week = localeWeek;
|
4150 | proto$1.firstDayOfYear = localeFirstDayOfYear;
|
4151 | proto$1.firstDayOfWeek = localeFirstDayOfWeek;
|
4152 | proto$1.weekdays = localeWeekdays;
|
4153 | proto$1.weekdaysMin = localeWeekdaysMin;
|
4154 | proto$1.weekdaysShort = localeWeekdaysShort;
|
4155 | proto$1.weekdaysParse = localeWeekdaysParse;
|
4156 | proto$1.weekdaysRegex = weekdaysRegex;
|
4157 | proto$1.weekdaysShortRegex = weekdaysShortRegex;
|
4158 | proto$1.weekdaysMinRegex = weekdaysMinRegex;
|
4159 | proto$1.isPM = localeIsPM;
|
4160 | proto$1.meridiem = localeMeridiem;
|
4161 |
|
4162 | function get$1(format, index, field, setter) {
|
4163 | var locale = getLocale();
|
4164 | var utc = createUTC().set(setter, index);
|
4165 | return locale[field](utc, format);
|
4166 | }
|
4167 |
|
4168 | function listMonthsImpl(format, index, field) {
|
4169 | if (isNumber(format)) {
|
4170 | index = format;
|
4171 | format = undefined;
|
4172 | }
|
4173 |
|
4174 | format = format || '';
|
4175 |
|
4176 | if (index != null) {
|
4177 | return get$1(format, index, field, 'month');
|
4178 | }
|
4179 |
|
4180 | var i;
|
4181 | var out = [];
|
4182 |
|
4183 | for (i = 0; i < 12; i++) {
|
4184 | out[i] = get$1(format, i, field, 'month');
|
4185 | }
|
4186 |
|
4187 | return out;
|
4188 | } // ()
|
4189 | // (5)
|
4190 | // (fmt, 5)
|
4191 | // (fmt)
|
4192 | // (true)
|
4193 | // (true, 5)
|
4194 | // (true, fmt, 5)
|
4195 | // (true, fmt)
|
4196 |
|
4197 |
|
4198 | function listWeekdaysImpl(localeSorted, format, index, field) {
|
4199 | if (typeof localeSorted === 'boolean') {
|
4200 | if (isNumber(format)) {
|
4201 | index = format;
|
4202 | format = undefined;
|
4203 | }
|
4204 |
|
4205 | format = format || '';
|
4206 | } else {
|
4207 | format = localeSorted;
|
4208 | index = format;
|
4209 | localeSorted = false;
|
4210 |
|
4211 | if (isNumber(format)) {
|
4212 | index = format;
|
4213 | format = undefined;
|
4214 | }
|
4215 |
|
4216 | format = format || '';
|
4217 | }
|
4218 |
|
4219 | var locale = getLocale(),
|
4220 | shift = localeSorted ? locale._week.dow : 0;
|
4221 |
|
4222 | if (index != null) {
|
4223 | return get$1(format, (index + shift) % 7, field, 'day');
|
4224 | }
|
4225 |
|
4226 | var i;
|
4227 | var out = [];
|
4228 |
|
4229 | for (i = 0; i < 7; i++) {
|
4230 | out[i] = get$1(format, (i + shift) % 7, field, 'day');
|
4231 | }
|
4232 |
|
4233 | return out;
|
4234 | }
|
4235 |
|
4236 | function listMonths(format, index) {
|
4237 | return listMonthsImpl(format, index, 'months');
|
4238 | }
|
4239 |
|
4240 | function listMonthsShort(format, index) {
|
4241 | return listMonthsImpl(format, index, 'monthsShort');
|
4242 | }
|
4243 |
|
4244 | function listWeekdays(localeSorted, format, index) {
|
4245 | return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
4246 | }
|
4247 |
|
4248 | function listWeekdaysShort(localeSorted, format, index) {
|
4249 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
4250 | }
|
4251 |
|
4252 | function listWeekdaysMin(localeSorted, format, index) {
|
4253 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
4254 | }
|
4255 |
|
4256 | getSetGlobalLocale('en', {
|
4257 | dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
4258 | ordinal: function (number) {
|
4259 | var b = number % 10,
|
4260 | output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
4261 | return number + output;
|
4262 | }
|
4263 | });
|
4264 |
|
4265 | hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
|
4266 | hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
|
4267 | var mathAbs = Math.abs;
|
4268 |
|
4269 | function abs() {
|
4270 | var data = this._data;
|
4271 | this._milliseconds = mathAbs(this._milliseconds);
|
4272 | this._days = mathAbs(this._days);
|
4273 | this._months = mathAbs(this._months);
|
4274 | data.milliseconds = mathAbs(data.milliseconds);
|
4275 | data.seconds = mathAbs(data.seconds);
|
4276 | data.minutes = mathAbs(data.minutes);
|
4277 | data.hours = mathAbs(data.hours);
|
4278 | data.months = mathAbs(data.months);
|
4279 | data.years = mathAbs(data.years);
|
4280 | return this;
|
4281 | }
|
4282 |
|
4283 | function addSubtract$1(duration, input, value, direction) {
|
4284 | var other = createDuration(input, value);
|
4285 | duration._milliseconds += direction * other._milliseconds;
|
4286 | duration._days += direction * other._days;
|
4287 | duration._months += direction * other._months;
|
4288 | return duration._bubble();
|
4289 | }
|
4290 |
|
4291 |
|
4292 | function add$1(input, value) {
|
4293 | return addSubtract$1(this, input, value, 1);
|
4294 | }
|
4295 |
|
4296 |
|
4297 | function subtract$1(input, value) {
|
4298 | return addSubtract$1(this, input, value, -1);
|
4299 | }
|
4300 |
|
4301 | function absCeil(number) {
|
4302 | if (number < 0) {
|
4303 | return Math.floor(number);
|
4304 | } else {
|
4305 | return Math.ceil(number);
|
4306 | }
|
4307 | }
|
4308 |
|
4309 | function bubble() {
|
4310 | var milliseconds = this._milliseconds;
|
4311 | var days = this._days;
|
4312 | var months = this._months;
|
4313 | var data = this._data;
|
4314 | var seconds, minutes, hours, years, monthsFromDays;
|
4315 |
|
4316 |
|
4317 | if (!(milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0)) {
|
4318 | milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
|
4319 | days = 0;
|
4320 | months = 0;
|
4321 | }
|
4322 |
|
4323 |
|
4324 |
|
4325 | data.milliseconds = milliseconds % 1000;
|
4326 | seconds = absFloor(milliseconds / 1000);
|
4327 | data.seconds = seconds % 60;
|
4328 | minutes = absFloor(seconds / 60);
|
4329 | data.minutes = minutes % 60;
|
4330 | hours = absFloor(minutes / 60);
|
4331 | data.hours = hours % 24;
|
4332 | days += absFloor(hours / 24);
|
4333 |
|
4334 | monthsFromDays = absFloor(daysToMonths(days));
|
4335 | months += monthsFromDays;
|
4336 | days -= absCeil(monthsToDays(monthsFromDays));
|
4337 |
|
4338 | years = absFloor(months / 12);
|
4339 | months %= 12;
|
4340 | data.days = days;
|
4341 | data.months = months;
|
4342 | data.years = years;
|
4343 | return this;
|
4344 | }
|
4345 |
|
4346 | function daysToMonths(days) {
|
4347 |
|
4348 |
|
4349 | return days * 4800 / 146097;
|
4350 | }
|
4351 |
|
4352 | function monthsToDays(months) {
|
4353 |
|
4354 | return months * 146097 / 4800;
|
4355 | }
|
4356 |
|
4357 | function as(units) {
|
4358 | if (!this.isValid()) {
|
4359 | return NaN;
|
4360 | }
|
4361 |
|
4362 | var days;
|
4363 | var months;
|
4364 | var milliseconds = this._milliseconds;
|
4365 | units = normalizeUnits(units);
|
4366 |
|
4367 | if (units === 'month' || units === 'quarter' || units === 'year') {
|
4368 | days = this._days + milliseconds / 864e5;
|
4369 | months = this._months + daysToMonths(days);
|
4370 |
|
4371 | switch (units) {
|
4372 | case 'month':
|
4373 | return months;
|
4374 |
|
4375 | case 'quarter':
|
4376 | return months / 3;
|
4377 |
|
4378 | case 'year':
|
4379 | return months / 12;
|
4380 | }
|
4381 | } else {
|
4382 |
|
4383 | days = this._days + Math.round(monthsToDays(this._months));
|
4384 |
|
4385 | switch (units) {
|
4386 | case 'week':
|
4387 | return days / 7 + milliseconds / 6048e5;
|
4388 |
|
4389 | case 'day':
|
4390 | return days + milliseconds / 864e5;
|
4391 |
|
4392 | case 'hour':
|
4393 | return days * 24 + milliseconds / 36e5;
|
4394 |
|
4395 | case 'minute':
|
4396 | return days * 1440 + milliseconds / 6e4;
|
4397 |
|
4398 | case 'second':
|
4399 | return days * 86400 + milliseconds / 1000;
|
4400 |
|
4401 |
|
4402 | case 'millisecond':
|
4403 | return Math.floor(days * 864e5) + milliseconds;
|
4404 |
|
4405 | default:
|
4406 | throw new Error('Unknown unit ' + units);
|
4407 | }
|
4408 | }
|
4409 | }
|
4410 |
|
4411 |
|
4412 | function valueOf$1() {
|
4413 | if (!this.isValid()) {
|
4414 | return NaN;
|
4415 | }
|
4416 |
|
4417 | return this._milliseconds + this._days * 864e5 + this._months % 12 * 2592e6 + toInt(this._months / 12) * 31536e6;
|
4418 | }
|
4419 |
|
4420 | function makeAs(alias) {
|
4421 | return function () {
|
4422 | return this.as(alias);
|
4423 | };
|
4424 | }
|
4425 |
|
4426 | var asMilliseconds = makeAs('ms');
|
4427 | var asSeconds = makeAs('s');
|
4428 | var asMinutes = makeAs('m');
|
4429 | var asHours = makeAs('h');
|
4430 | var asDays = makeAs('d');
|
4431 | var asWeeks = makeAs('w');
|
4432 | var asMonths = makeAs('M');
|
4433 | var asQuarters = makeAs('Q');
|
4434 | var asYears = makeAs('y');
|
4435 |
|
4436 | function clone$1() {
|
4437 | return createDuration(this);
|
4438 | }
|
4439 |
|
4440 | function get$2(units) {
|
4441 | units = normalizeUnits(units);
|
4442 | return this.isValid() ? this[units + 's']() : NaN;
|
4443 | }
|
4444 |
|
4445 | function makeGetter(name) {
|
4446 | return function () {
|
4447 | return this.isValid() ? this._data[name] : NaN;
|
4448 | };
|
4449 | }
|
4450 |
|
4451 | var milliseconds = makeGetter('milliseconds');
|
4452 | var seconds = makeGetter('seconds');
|
4453 | var minutes = makeGetter('minutes');
|
4454 | var hours = makeGetter('hours');
|
4455 | var days = makeGetter('days');
|
4456 | var months = makeGetter('months');
|
4457 | var years = makeGetter('years');
|
4458 |
|
4459 | function weeks() {
|
4460 | return absFloor(this.days() / 7);
|
4461 | }
|
4462 |
|
4463 | var round = Math.round;
|
4464 | var thresholds = {
|
4465 | ss: 44,
|
4466 |
|
4467 | s: 45,
|
4468 |
|
4469 | m: 45,
|
4470 |
|
4471 | h: 22,
|
4472 |
|
4473 | d: 26,
|
4474 |
|
4475 | M: 11
|
4476 |
|
4477 | };
|
4478 |
|
4479 | function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
4480 | return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
4481 | }
|
4482 |
|
4483 | function relativeTime$1(posNegDuration, withoutSuffix, locale) {
|
4484 | var duration = createDuration(posNegDuration).abs();
|
4485 | var seconds = round(duration.as('s'));
|
4486 | var minutes = round(duration.as('m'));
|
4487 | var hours = round(duration.as('h'));
|
4488 | var days = round(duration.as('d'));
|
4489 | var months = round(duration.as('M'));
|
4490 | var years = round(duration.as('y'));
|
4491 | var a = seconds <= thresholds.ss && ['s', seconds] || seconds < thresholds.s && ['ss', seconds] || minutes <= 1 && ['m'] || minutes < thresholds.m && ['mm', minutes] || hours <= 1 && ['h'] || hours < thresholds.h && ['hh', hours] || days <= 1 && ['d'] || days < thresholds.d && ['dd', days] || months <= 1 && ['M'] || months < thresholds.M && ['MM', months] || years <= 1 && ['y'] || ['yy', years];
|
4492 | a[2] = withoutSuffix;
|
4493 | a[3] = +posNegDuration > 0;
|
4494 | a[4] = locale;
|
4495 | return substituteTimeAgo.apply(null, a);
|
4496 | }
|
4497 |
|
4498 |
|
4499 | function getSetRelativeTimeRounding(roundingFunction) {
|
4500 | if (roundingFunction === undefined) {
|
4501 | return round;
|
4502 | }
|
4503 |
|
4504 | if (typeof roundingFunction === 'function') {
|
4505 | round = roundingFunction;
|
4506 | return true;
|
4507 | }
|
4508 |
|
4509 | return false;
|
4510 | }
|
4511 |
|
4512 |
|
4513 | function getSetRelativeTimeThreshold(threshold, limit) {
|
4514 | if (thresholds[threshold] === undefined) {
|
4515 | return false;
|
4516 | }
|
4517 |
|
4518 | if (limit === undefined) {
|
4519 | return thresholds[threshold];
|
4520 | }
|
4521 |
|
4522 | thresholds[threshold] = limit;
|
4523 |
|
4524 | if (threshold === 's') {
|
4525 | thresholds.ss = limit - 1;
|
4526 | }
|
4527 |
|
4528 | return true;
|
4529 | }
|
4530 |
|
4531 | function humanize(withSuffix) {
|
4532 | if (!this.isValid()) {
|
4533 | return this.localeData().invalidDate();
|
4534 | }
|
4535 |
|
4536 | var locale = this.localeData();
|
4537 | var output = relativeTime$1(this, !withSuffix, locale);
|
4538 |
|
4539 | if (withSuffix) {
|
4540 | output = locale.pastFuture(+this, output);
|
4541 | }
|
4542 |
|
4543 | return locale.postformat(output);
|
4544 | }
|
4545 |
|
4546 | var abs$1 = Math.abs;
|
4547 |
|
4548 | function sign(x) {
|
4549 | return (x > 0) - (x < 0) || +x;
|
4550 | }
|
4551 |
|
4552 | function toISOString$1() {
|
4553 |
|
4554 |
|
4555 |
|
4556 |
|
4557 |
|
4558 |
|
4559 |
|
4560 | if (!this.isValid()) {
|
4561 | return this.localeData().invalidDate();
|
4562 | }
|
4563 |
|
4564 | var seconds = abs$1(this._milliseconds) / 1000;
|
4565 | var days = abs$1(this._days);
|
4566 | var months = abs$1(this._months);
|
4567 | var minutes, hours, years;
|
4568 |
|
4569 | minutes = absFloor(seconds / 60);
|
4570 | hours = absFloor(minutes / 60);
|
4571 | seconds %= 60;
|
4572 | minutes %= 60;
|
4573 |
|
4574 | years = absFloor(months / 12);
|
4575 | months %= 12;
|
4576 |
|
4577 | var Y = years;
|
4578 | var M = months;
|
4579 | var D = days;
|
4580 | var h = hours;
|
4581 | var m = minutes;
|
4582 | var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
|
4583 | var total = this.asSeconds();
|
4584 |
|
4585 | if (!total) {
|
4586 |
|
4587 |
|
4588 | return 'P0D';
|
4589 | }
|
4590 |
|
4591 | var totalSign = total < 0 ? '-' : '';
|
4592 | var ymSign = sign(this._months) !== sign(total) ? '-' : '';
|
4593 | var daysSign = sign(this._days) !== sign(total) ? '-' : '';
|
4594 | var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
|
4595 | return totalSign + 'P' + (Y ? ymSign + Y + 'Y' : '') + (M ? ymSign + M + 'M' : '') + (D ? daysSign + D + 'D' : '') + (h || m || s ? 'T' : '') + (h ? hmsSign + h + 'H' : '') + (m ? hmsSign + m + 'M' : '') + (s ? hmsSign + s + 'S' : '');
|
4596 | }
|
4597 |
|
4598 | var proto$2 = Duration.prototype;
|
4599 | proto$2.isValid = isValid$1;
|
4600 | proto$2.abs = abs;
|
4601 | proto$2.add = add$1;
|
4602 | proto$2.subtract = subtract$1;
|
4603 | proto$2.as = as;
|
4604 | proto$2.asMilliseconds = asMilliseconds;
|
4605 | proto$2.asSeconds = asSeconds;
|
4606 | proto$2.asMinutes = asMinutes;
|
4607 | proto$2.asHours = asHours;
|
4608 | proto$2.asDays = asDays;
|
4609 | proto$2.asWeeks = asWeeks;
|
4610 | proto$2.asMonths = asMonths;
|
4611 | proto$2.asQuarters = asQuarters;
|
4612 | proto$2.asYears = asYears;
|
4613 | proto$2.valueOf = valueOf$1;
|
4614 | proto$2._bubble = bubble;
|
4615 | proto$2.clone = clone$1;
|
4616 | proto$2.get = get$2;
|
4617 | proto$2.milliseconds = milliseconds;
|
4618 | proto$2.seconds = seconds;
|
4619 | proto$2.minutes = minutes;
|
4620 | proto$2.hours = hours;
|
4621 | proto$2.days = days;
|
4622 | proto$2.weeks = weeks;
|
4623 | proto$2.months = months;
|
4624 | proto$2.years = years;
|
4625 | proto$2.humanize = humanize;
|
4626 | proto$2.toISOString = toISOString$1;
|
4627 | proto$2.toString = toISOString$1;
|
4628 | proto$2.toJSON = toISOString$1;
|
4629 | proto$2.locale = locale;
|
4630 | proto$2.localeData = localeData;
|
4631 | proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
|
4632 | proto$2.lang = lang; // Side effect imports
|
4633 | // FORMATTING
|
4634 |
|
4635 | addFormatToken('X', 0, 0, 'unix');
|
4636 | addFormatToken('x', 0, 0, 'valueOf'); // PARSING
|
4637 |
|
4638 | addRegexToken('x', matchSigned);
|
4639 | addRegexToken('X', matchTimestamp);
|
4640 | addParseToken('X', function (input, array, config) {
|
4641 | config._d = new Date(parseFloat(input, 10) * 1000);
|
4642 | });
|
4643 | addParseToken('x', function (input, array, config) {
|
4644 | config._d = new Date(toInt(input));
|
4645 | });
|
4646 |
|
4647 | hooks.version = '2.24.0';
|
4648 | setHookCallback(createLocal);
|
4649 | hooks.fn = proto;
|
4650 | hooks.min = min;
|
4651 | hooks.max = max;
|
4652 | hooks.now = now;
|
4653 | hooks.utc = createUTC;
|
4654 | hooks.unix = createUnix;
|
4655 | hooks.months = listMonths;
|
4656 | hooks.isDate = isDate;
|
4657 | hooks.locale = getSetGlobalLocale;
|
4658 | hooks.invalid = createInvalid;
|
4659 | hooks.duration = createDuration;
|
4660 | hooks.isMoment = isMoment;
|
4661 | hooks.weekdays = listWeekdays;
|
4662 | hooks.parseZone = createInZone;
|
4663 | hooks.localeData = getLocale;
|
4664 | hooks.isDuration = isDuration;
|
4665 | hooks.monthsShort = listMonthsShort;
|
4666 | hooks.weekdaysMin = listWeekdaysMin;
|
4667 | hooks.defineLocale = defineLocale;
|
4668 | hooks.updateLocale = updateLocale;
|
4669 | hooks.locales = listLocales;
|
4670 | hooks.weekdaysShort = listWeekdaysShort;
|
4671 | hooks.normalizeUnits = normalizeUnits;
|
4672 | hooks.relativeTimeRounding = getSetRelativeTimeRounding;
|
4673 | hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
|
4674 | hooks.calendarFormat = getCalendarFormat;
|
4675 | hooks.prototype = proto;
|
4676 |
|
4677 | hooks.HTML5_FMT = {
|
4678 | DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm',
|
4679 |
|
4680 | DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss',
|
4681 |
|
4682 | DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS',
|
4683 |
|
4684 | DATE: 'YYYY-MM-DD',
|
4685 |
|
4686 | TIME: 'HH:mm',
|
4687 |
|
4688 | TIME_SECONDS: 'HH:mm:ss',
|
4689 |
|
4690 | TIME_MS: 'HH:mm:ss.SSS',
|
4691 |
|
4692 | WEEK: 'GGGG-[W]WW',
|
4693 |
|
4694 | MONTH: 'YYYY-MM'
|
4695 |
|
4696 | };
|
4697 | return hooks;
|
4698 | });
|
4699 | });
|
4700 |
|
4701 | var byteToHex = [];
|
4702 |
|
4703 | for (var i = 0; i < 256; i++) {
|
4704 | byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
4705 | }
|
4706 |
|
4707 |
|
4708 |
|
4709 |
|
4710 |
|
4711 |
|
4712 |
|
4713 |
|
4714 |
|
4715 |
|
4716 | function stringifyUUID(buf, offset) {
|
4717 | var i = offset || 0;
|
4718 | var bth = byteToHex;
|
4719 | 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++]];
|
4720 | }
|
4721 |
|
4722 |
|
4723 |
|
4724 |
|
4725 |
|
4726 |
|
4727 |
|
4728 | var random = function () {
|
4729 | if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
4730 |
|
4731 |
|
4732 | var _rnds8 = new Uint8Array(16);
|
4733 |
|
4734 | return function whatwgRNG() {
|
4735 | crypto.getRandomValues(_rnds8);
|
4736 | return _rnds8;
|
4737 | };
|
4738 | }
|
4739 |
|
4740 |
|
4741 |
|
4742 |
|
4743 |
|
4744 | var _rnds = new Array(16);
|
4745 |
|
4746 | return function () {
|
4747 | for (var i = 0, r; i < 16; i++) {
|
4748 | if ((i & 0x03) === 0) {
|
4749 | r = Math.random() * 0x100000000;
|
4750 | }
|
4751 |
|
4752 | _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
4753 | }
|
4754 |
|
4755 | return _rnds;
|
4756 | };
|
4757 |
|
4758 |
|
4759 |
|
4760 |
|
4761 |
|
4762 |
|
4763 |
|
4764 | }();
|
4765 |
|
4766 | var byteToHex$1 = [];
|
4767 |
|
4768 | for (var i$1 = 0; i$1 < 256; i$1++) {
|
4769 | byteToHex$1[i$1] = (i$1 + 0x100).toString(16).substr(1);
|
4770 | }
|
4771 |
|
4772 |
|
4773 |
|
4774 |
|
4775 |
|
4776 |
|
4777 | var seedBytes = random();
|
4778 |
|
4779 | var defaultNodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
|
4780 |
|
4781 | var defaultClockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
|
4782 |
|
4783 |
|
4784 |
|
4785 |
|
4786 |
|
4787 |
|
4788 |
|
4789 |
|
4790 |
|
4791 |
|
4792 |
|
4793 |
|
4794 |
|
4795 |
|
4796 |
|
4797 |
|
4798 | function uuid4() {
|
4799 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
4800 | var buf = arguments.length > 1 ? arguments[1] : undefined;
|
4801 | var offset = arguments.length > 2 ? arguments[2] : undefined;
|
4802 |
|
4803 | var i = buf && offset || 0;
|
4804 |
|
4805 | if (typeof options === 'string') {
|
4806 | buf = options === 'binary' ? new Array(16) : undefined;
|
4807 | options = {};
|
4808 | }
|
4809 |
|
4810 | var rnds = options.random || (options.rng || random)();
|
4811 |
|
4812 | rnds[6] = rnds[6] & 0x0f | 0x40;
|
4813 | rnds[8] = rnds[8] & 0x3f | 0x80;
|
4814 |
|
4815 | if (buf) {
|
4816 | for (var ii = 0; ii < 16; ii++) {
|
4817 | buf[i + ii] = rnds[ii];
|
4818 | }
|
4819 | }
|
4820 |
|
4821 | return buf || stringifyUUID(rnds);
|
4822 | }
|
4823 |
|
4824 |
|
4825 |
|
4826 |
|
4827 | var ASPDateRegex = /^\/?Date\((-?\d+)/i;
|
4828 |
|
4829 | var fullHexRE = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
4830 | var shortHexRE = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
4831 |
|
4832 |
|
4833 |
|
4834 |
|
4835 |
|
4836 |
|
4837 |
|
4838 |
|
4839 |
|
4840 |
|
4841 |
|
4842 |
|
4843 | function isNumber(value) {
|
4844 | return value instanceof Number || typeof value === 'number';
|
4845 | }
|
4846 |
|
4847 |
|
4848 |
|
4849 |
|
4850 |
|
4851 |
|
4852 |
|
4853 | function recursiveDOMDelete(DOMobject) {
|
4854 | if (DOMobject) {
|
4855 | while (DOMobject.hasChildNodes() === true) {
|
4856 | var child = DOMobject.firstChild;
|
4857 |
|
4858 | if (child) {
|
4859 | recursiveDOMDelete(child);
|
4860 | DOMobject.removeChild(child);
|
4861 | }
|
4862 | }
|
4863 | }
|
4864 | }
|
4865 |
|
4866 |
|
4867 |
|
4868 |
|
4869 |
|
4870 |
|
4871 |
|
4872 |
|
4873 |
|
4874 | function isString(value) {
|
4875 | return value instanceof String || typeof value === 'string';
|
4876 | }
|
4877 |
|
4878 |
|
4879 |
|
4880 |
|
4881 |
|
4882 |
|
4883 |
|
4884 |
|
4885 |
|
4886 | function isObject(value) {
|
4887 | return _typeof(value) === 'object' && value !== null;
|
4888 | }
|
4889 |
|
4890 |
|
4891 |
|
4892 |
|
4893 |
|
4894 |
|
4895 |
|
4896 |
|
4897 |
|
4898 | function isDate(value) {
|
4899 | if (value instanceof Date) {
|
4900 | return true;
|
4901 | } else if (isString(value)) {
|
4902 |
|
4903 | var match = ASPDateRegex.exec(value);
|
4904 |
|
4905 | if (match) {
|
4906 | return true;
|
4907 | } else if (!isNaN(Date.parse(value))) {
|
4908 | return true;
|
4909 | }
|
4910 | }
|
4911 |
|
4912 | return false;
|
4913 | }
|
4914 |
|
4915 |
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 |
|
4921 |
|
4922 |
|
4923 |
|
4924 | function isMoment(value) {
|
4925 | return moment.isMoment(value);
|
4926 | }
|
4927 |
|
4928 |
|
4929 |
|
4930 |
|
4931 |
|
4932 |
|
4933 |
|
4934 |
|
4935 |
|
4936 |
|
4937 |
|
4938 |
|
4939 |
|
4940 | function copyOrDelete(a, b, prop, allowDeletion) {
|
4941 | var doDeletion = false;
|
4942 |
|
4943 | if (allowDeletion === true) {
|
4944 | doDeletion = b[prop] === null && a[prop] !== undefined;
|
4945 | }
|
4946 |
|
4947 | if (doDeletion) {
|
4948 | delete a[prop];
|
4949 | } else {
|
4950 | a[prop] = b[prop];
|
4951 | }
|
4952 | }
|
4953 |
|
4954 |
|
4955 |
|
4956 |
|
4957 |
|
4958 |
|
4959 |
|
4960 |
|
4961 |
|
4962 |
|
4963 |
|
4964 |
|
4965 | function fillIfDefined(a, b) {
|
4966 | var allowDeletion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
4967 |
|
4968 |
|
4969 | for (var prop in a) {
|
4970 | if (b[prop] !== undefined) {
|
4971 | if (b[prop] === null || _typeof(b[prop]) !== 'object') {
|
4972 |
|
4973 | copyOrDelete(a, b, prop, allowDeletion);
|
4974 | } else {
|
4975 | var aProp = a[prop];
|
4976 | var bProp = b[prop];
|
4977 |
|
4978 | if (isObject(aProp) && isObject(bProp)) {
|
4979 | fillIfDefined(aProp, bProp, allowDeletion);
|
4980 | }
|
4981 | }
|
4982 | }
|
4983 | }
|
4984 | }
|
4985 |
|
4986 |
|
4987 |
|
4988 |
|
4989 |
|
4990 |
|
4991 |
|
4992 |
|
4993 |
|
4994 |
|
4995 |
|
4996 | var extend = Object.assign;
|
4997 |
|
4998 |
|
4999 |
|
5000 |
|
5001 |
|
5002 |
|
5003 |
|
5004 |
|
5005 |
|
5006 |
|
5007 |
|
5008 | function selectiveExtend(props, a) {
|
5009 |
|
5010 | if (!Array.isArray(props)) {
|
5011 | throw new Error('Array with property names expected as first argument');
|
5012 | }
|
5013 |
|
5014 | for (var i = 2; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) {
|
5015 | var other = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2];
|
5016 |
|
5017 | for (var p = 0; p < props.length; p++) {
|
5018 | var prop = props[p];
|
5019 |
|
5020 | if (other && Object.prototype.hasOwnProperty.call(other, prop)) {
|
5021 | a[prop] = other[prop];
|
5022 | }
|
5023 | }
|
5024 | }
|
5025 |
|
5026 | return a;
|
5027 | }
|
5028 |
|
5029 |
|
5030 |
|
5031 |
|
5032 |
|
5033 |
|
5034 |
|
5035 |
|
5036 |
|
5037 |
|
5038 |
|
5039 |
|
5040 |
|
5041 |
|
5042 |
|
5043 |
|
5044 |
|
5045 |
|
5046 | function selectiveDeepExtend(props, a, b) {
|
5047 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
5048 |
|
5049 | if (Array.isArray(b)) {
|
5050 | throw new TypeError('Arrays are not supported by deepExtend');
|
5051 | }
|
5052 |
|
5053 | for (var p = 0; p < props.length; p++) {
|
5054 | var prop = props[p];
|
5055 |
|
5056 | if (Object.prototype.hasOwnProperty.call(b, prop)) {
|
5057 | if (b[prop] && b[prop].constructor === Object) {
|
5058 | if (a[prop] === undefined) {
|
5059 | a[prop] = {};
|
5060 | }
|
5061 |
|
5062 | if (a[prop].constructor === Object) {
|
5063 | deepExtend(a[prop], b[prop], false, allowDeletion);
|
5064 | } else {
|
5065 | copyOrDelete(a, b, prop, allowDeletion);
|
5066 | }
|
5067 | } else if (Array.isArray(b[prop])) {
|
5068 | throw new TypeError('Arrays are not supported by deepExtend');
|
5069 | } else {
|
5070 | copyOrDelete(a, b, prop, allowDeletion);
|
5071 | }
|
5072 | }
|
5073 | }
|
5074 |
|
5075 | return a;
|
5076 | }
|
5077 |
|
5078 |
|
5079 |
|
5080 |
|
5081 |
|
5082 |
|
5083 |
|
5084 |
|
5085 |
|
5086 |
|
5087 |
|
5088 |
|
5089 |
|
5090 |
|
5091 |
|
5092 |
|
5093 |
|
5094 | function selectiveNotDeepExtend(propsToExclude, a, b) {
|
5095 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
5096 |
|
5097 |
|
5098 | if (Array.isArray(b)) {
|
5099 | throw new TypeError('Arrays are not supported by deepExtend');
|
5100 | }
|
5101 |
|
5102 | for (var prop in b) {
|
5103 | if (!Object.prototype.hasOwnProperty.call(b, prop)) {
|
5104 | continue;
|
5105 | }
|
5106 |
|
5107 |
|
5108 | if (propsToExclude.indexOf(prop) !== -1) {
|
5109 | continue;
|
5110 | }
|
5111 |
|
5112 |
|
5113 | if (b[prop] && b[prop].constructor === Object) {
|
5114 | if (a[prop] === undefined) {
|
5115 | a[prop] = {};
|
5116 | }
|
5117 |
|
5118 | if (a[prop].constructor === Object) {
|
5119 | deepExtend(a[prop], b[prop]);
|
5120 | } else {
|
5121 | copyOrDelete(a, b, prop, allowDeletion);
|
5122 | }
|
5123 | } else if (Array.isArray(b[prop])) {
|
5124 | a[prop] = [];
|
5125 |
|
5126 | for (var i = 0; i < b[prop].length; i++) {
|
5127 | a[prop].push(b[prop][i]);
|
5128 | }
|
5129 | } else {
|
5130 | copyOrDelete(a, b, prop, allowDeletion);
|
5131 | }
|
5132 | }
|
5133 |
|
5134 | return a;
|
5135 | }
|
5136 |
|
5137 |
|
5138 |
|
5139 |
|
5140 |
|
5141 |
|
5142 |
|
5143 |
|
5144 |
|
5145 |
|
5146 |
|
5147 |
|
5148 |
|
5149 | function deepExtend(a, b) {
|
5150 | var protoExtend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
5151 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
5152 |
|
5153 | for (var prop in b) {
|
5154 | if (Object.prototype.hasOwnProperty.call(b, prop) || protoExtend === true) {
|
5155 | if (b[prop] && b[prop].constructor === Object) {
|
5156 | if (a[prop] === undefined) {
|
5157 | a[prop] = {};
|
5158 | }
|
5159 |
|
5160 | if (a[prop].constructor === Object) {
|
5161 | deepExtend(a[prop], b[prop], protoExtend);
|
5162 | } else {
|
5163 | copyOrDelete(a, b, prop, allowDeletion);
|
5164 | }
|
5165 | } else if (Array.isArray(b[prop])) {
|
5166 | a[prop] = [];
|
5167 |
|
5168 | for (var i = 0; i < b[prop].length; i++) {
|
5169 | a[prop].push(b[prop][i]);
|
5170 | }
|
5171 | } else {
|
5172 | copyOrDelete(a, b, prop, allowDeletion);
|
5173 | }
|
5174 | }
|
5175 | }
|
5176 |
|
5177 | return a;
|
5178 | }
|
5179 |
|
5180 |
|
5181 |
|
5182 |
|
5183 |
|
5184 |
|
5185 |
|
5186 |
|
5187 |
|
5188 |
|
5189 | function equalArray(a, b) {
|
5190 | if (a.length !== b.length) {
|
5191 | return false;
|
5192 | }
|
5193 |
|
5194 | for (var i = 0, len = a.length; i < len; i++) {
|
5195 | if (a[i] != b[i]) {
|
5196 | return false;
|
5197 | }
|
5198 | }
|
5199 |
|
5200 | return true;
|
5201 | }
|
5202 |
|
5203 |
|
5204 |
|
5205 |
|
5206 |
|
5207 |
|
5208 |
|
5209 |
|
5210 |
|
5211 |
|
5212 |
|
5213 | function convert(object, type) {
|
5214 | var match;
|
5215 |
|
5216 | if (object === undefined) {
|
5217 | return undefined;
|
5218 | }
|
5219 |
|
5220 | if (object === null) {
|
5221 | return null;
|
5222 | }
|
5223 |
|
5224 | if (!type) {
|
5225 | return object;
|
5226 | }
|
5227 |
|
5228 | if (!(typeof type === 'string') && !(type instanceof String)) {
|
5229 | throw new Error('Type must be a string');
|
5230 | }
|
5231 |
|
5232 |
|
5233 | switch (type) {
|
5234 | case 'boolean':
|
5235 | case 'Boolean':
|
5236 | return Boolean(object);
|
5237 |
|
5238 | case 'number':
|
5239 | case 'Number':
|
5240 | if (isString(object) && !isNaN(Date.parse(object))) {
|
5241 | return moment(object).valueOf();
|
5242 | } else {
|
5243 |
|
5244 |
|
5245 |
|
5246 | return Number(object.valueOf());
|
5247 | }
|
5248 |
|
5249 | case 'string':
|
5250 | case 'String':
|
5251 | return String(object);
|
5252 |
|
5253 | case 'Date':
|
5254 | if (isNumber(object)) {
|
5255 | return new Date(object);
|
5256 | }
|
5257 |
|
5258 | if (object instanceof Date) {
|
5259 | return new Date(object.valueOf());
|
5260 | } else if (isMoment(object)) {
|
5261 | return new Date(object.valueOf());
|
5262 | }
|
5263 |
|
5264 | if (isString(object)) {
|
5265 | match = ASPDateRegex.exec(object);
|
5266 |
|
5267 | if (match) {
|
5268 |
|
5269 | return new Date(Number(match[1]));
|
5270 | } else {
|
5271 | return moment(new Date(object)).toDate();
|
5272 | }
|
5273 | } else {
|
5274 | throw new Error('Cannot convert object of type ' + getType(object) + ' to type Date');
|
5275 | }
|
5276 |
|
5277 | case 'Moment':
|
5278 | if (isNumber(object)) {
|
5279 | return moment(object);
|
5280 | }
|
5281 |
|
5282 | if (object instanceof Date) {
|
5283 | return moment(object.valueOf());
|
5284 | } else if (isMoment(object)) {
|
5285 | return moment(object);
|
5286 | }
|
5287 |
|
5288 | if (isString(object)) {
|
5289 | match = ASPDateRegex.exec(object);
|
5290 |
|
5291 | if (match) {
|
5292 |
|
5293 | return moment(Number(match[1]));
|
5294 | } else {
|
5295 | return moment(object);
|
5296 | }
|
5297 | } else {
|
5298 | throw new Error('Cannot convert object of type ' + getType(object) + ' to type Date');
|
5299 | }
|
5300 |
|
5301 | case 'ISODate':
|
5302 | if (isNumber(object)) {
|
5303 | return new Date(object);
|
5304 | } else if (object instanceof Date) {
|
5305 | return object.toISOString();
|
5306 | } else if (isMoment(object)) {
|
5307 | return object.toDate().toISOString();
|
5308 | } else if (isString(object)) {
|
5309 | match = ASPDateRegex.exec(object);
|
5310 |
|
5311 | if (match) {
|
5312 |
|
5313 | return new Date(Number(match[1])).toISOString();
|
5314 | } else {
|
5315 | return moment(object).format();
|
5316 | }
|
5317 | } else {
|
5318 | throw new Error('Cannot convert object of type ' + getType(object) + ' to type ISODate');
|
5319 | }
|
5320 |
|
5321 | case 'ASPDate':
|
5322 | if (isNumber(object)) {
|
5323 | return '/Date(' + object + ')/';
|
5324 | } else if (object instanceof Date) {
|
5325 | return '/Date(' + object.valueOf() + ')/';
|
5326 | } else if (isString(object)) {
|
5327 | match = ASPDateRegex.exec(object);
|
5328 |
|
5329 | var _value;
|
5330 |
|
5331 | if (match) {
|
5332 |
|
5333 | _value = new Date(Number(match[1])).valueOf();
|
5334 | } else {
|
5335 | _value = new Date(object).valueOf();
|
5336 | }
|
5337 |
|
5338 | return '/Date(' + _value + ')/';
|
5339 | } else {
|
5340 | throw new Error('Cannot convert object of type ' + getType(object) + ' to type ASPDate');
|
5341 | }
|
5342 |
|
5343 | default:
|
5344 | var never = type;
|
5345 | throw new Error("Unknown type ".concat(never));
|
5346 | }
|
5347 | }
|
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 |
|
5355 |
|
5356 |
|
5357 | function getType(object) {
|
5358 | var type = _typeof(object);
|
5359 |
|
5360 | if (type === 'object') {
|
5361 | if (object === null) {
|
5362 | return 'null';
|
5363 | }
|
5364 |
|
5365 | if (object instanceof Boolean) {
|
5366 | return 'Boolean';
|
5367 | }
|
5368 |
|
5369 | if (object instanceof Number) {
|
5370 | return 'Number';
|
5371 | }
|
5372 |
|
5373 | if (object instanceof String) {
|
5374 | return 'String';
|
5375 | }
|
5376 |
|
5377 | if (Array.isArray(object)) {
|
5378 | return 'Array';
|
5379 | }
|
5380 |
|
5381 | if (object instanceof Date) {
|
5382 | return 'Date';
|
5383 | }
|
5384 |
|
5385 | return 'Object';
|
5386 | }
|
5387 |
|
5388 | if (type === 'number') {
|
5389 | return 'Number';
|
5390 | }
|
5391 |
|
5392 | if (type === 'boolean') {
|
5393 | return 'Boolean';
|
5394 | }
|
5395 |
|
5396 | if (type === 'string') {
|
5397 | return 'String';
|
5398 | }
|
5399 |
|
5400 | if (type === undefined) {
|
5401 | return 'undefined';
|
5402 | }
|
5403 |
|
5404 | return type;
|
5405 | }
|
5406 |
|
5407 |
|
5408 |
|
5409 |
|
5410 |
|
5411 |
|
5412 |
|
5413 |
|
5414 |
|
5415 |
|
5416 | function copyAndExtendArray(arr, newValue) {
|
5417 | return [].concat(_toConsumableArray(arr), [newValue]);
|
5418 | }
|
5419 |
|
5420 |
|
5421 |
|
5422 |
|
5423 |
|
5424 |
|
5425 |
|
5426 |
|
5427 |
|
5428 | function copyArray(arr) {
|
5429 | return arr.slice();
|
5430 | }
|
5431 |
|
5432 |
|
5433 |
|
5434 |
|
5435 |
|
5436 |
|
5437 |
|
5438 |
|
5439 |
|
5440 | function getAbsoluteLeft(elem) {
|
5441 | return elem.getBoundingClientRect().left;
|
5442 | }
|
5443 |
|
5444 |
|
5445 |
|
5446 |
|
5447 |
|
5448 |
|
5449 |
|
5450 |
|
5451 |
|
5452 | function getAbsoluteRight(elem) {
|
5453 | return elem.getBoundingClientRect().right;
|
5454 | }
|
5455 |
|
5456 |
|
5457 |
|
5458 |
|
5459 |
|
5460 |
|
5461 |
|
5462 |
|
5463 |
|
5464 | function getAbsoluteTop(elem) {
|
5465 | return elem.getBoundingClientRect().top;
|
5466 | }
|
5467 |
|
5468 |
|
5469 |
|
5470 |
|
5471 |
|
5472 |
|
5473 |
|
5474 |
|
5475 | function addClassName(elem, classNames) {
|
5476 | var classes = elem.className.split(' ');
|
5477 | var newClasses = classNames.split(' ');
|
5478 | classes = classes.concat(newClasses.filter(function (className) {
|
5479 | return classes.indexOf(className) < 0;
|
5480 | }));
|
5481 | elem.className = classes.join(' ');
|
5482 | }
|
5483 |
|
5484 |
|
5485 |
|
5486 |
|
5487 |
|
5488 |
|
5489 |
|
5490 |
|
5491 | function removeClassName(elem, classNames) {
|
5492 | var classes = elem.className.split(' ');
|
5493 | var oldClasses = classNames.split(' ');
|
5494 | classes = classes.filter(function (className) {
|
5495 | return oldClasses.indexOf(className) < 0;
|
5496 | });
|
5497 | elem.className = classes.join(' ');
|
5498 | }
|
5499 |
|
5500 |
|
5501 |
|
5502 |
|
5503 |
|
5504 |
|
5505 |
|
5506 |
|
5507 |
|
5508 |
|
5509 | function forEach(object, callback) {
|
5510 | if (Array.isArray(object)) {
|
5511 |
|
5512 | var len = object.length;
|
5513 |
|
5514 | for (var i = 0; i < len; i++) {
|
5515 | callback(object[i], i, object);
|
5516 | }
|
5517 | } else {
|
5518 |
|
5519 | for (var _key in object) {
|
5520 | if (Object.prototype.hasOwnProperty.call(object, _key)) {
|
5521 | callback(object[_key], _key, object);
|
5522 | }
|
5523 | }
|
5524 | }
|
5525 | }
|
5526 |
|
5527 |
|
5528 |
|
5529 |
|
5530 |
|
5531 |
|
5532 |
|
5533 |
|
5534 |
|
5535 | var toArray = Object.values;
|
5536 |
|
5537 |
|
5538 |
|
5539 |
|
5540 |
|
5541 |
|
5542 |
|
5543 |
|
5544 |
|
5545 |
|
5546 | function updateProperty(object, key, value) {
|
5547 | if (object[key] !== value) {
|
5548 | object[key] = value;
|
5549 | return true;
|
5550 | } else {
|
5551 | return false;
|
5552 | }
|
5553 | }
|
5554 |
|
5555 |
|
5556 |
|
5557 |
|
5558 |
|
5559 |
|
5560 |
|
5561 |
|
5562 |
|
5563 | function throttle(fn) {
|
5564 | var scheduled = false;
|
5565 | return function () {
|
5566 | if (!scheduled) {
|
5567 | scheduled = true;
|
5568 | requestAnimationFrame(function () {
|
5569 | scheduled = false;
|
5570 | fn();
|
5571 | });
|
5572 | }
|
5573 | };
|
5574 | }
|
5575 |
|
5576 |
|
5577 |
|
5578 |
|
5579 |
|
5580 |
|
5581 |
|
5582 |
|
5583 |
|
5584 |
|
5585 | function addEventListener(element, action, listener, useCapture) {
|
5586 | if (element.addEventListener) {
|
5587 | if (useCapture === undefined) {
|
5588 | useCapture = false;
|
5589 | }
|
5590 |
|
5591 | if (action === 'mousewheel' && navigator.userAgent.indexOf('Firefox') >= 0) {
|
5592 | action = 'DOMMouseScroll';
|
5593 | }
|
5594 |
|
5595 | element.addEventListener(action, listener, useCapture);
|
5596 | } else {
|
5597 | element.attachEvent('on' + action, listener);
|
5598 | }
|
5599 | }
|
5600 |
|
5601 |
|
5602 |
|
5603 |
|
5604 |
|
5605 |
|
5606 |
|
5607 |
|
5608 |
|
5609 |
|
5610 | function removeEventListener(element, action, listener, useCapture) {
|
5611 | if (element.removeEventListener) {
|
5612 |
|
5613 | if (useCapture === undefined) {
|
5614 | useCapture = false;
|
5615 | }
|
5616 |
|
5617 | if (action === 'mousewheel' && navigator.userAgent.indexOf('Firefox') >= 0) {
|
5618 | action = 'DOMMouseScroll';
|
5619 | }
|
5620 |
|
5621 | element.removeEventListener(action, listener, useCapture);
|
5622 | } else {
|
5623 | element.detachEvent('on' + action, listener);
|
5624 | }
|
5625 | }
|
5626 |
|
5627 |
|
5628 |
|
5629 |
|
5630 |
|
5631 |
|
5632 |
|
5633 | function preventDefault(event) {
|
5634 | if (!event) {
|
5635 | event = window.event;
|
5636 | }
|
5637 |
|
5638 | if (!event) ;else if (event.preventDefault) {
|
5639 | event.preventDefault();
|
5640 | } else {
|
5641 | event.returnValue = false;
|
5642 | }
|
5643 | }
|
5644 |
|
5645 |
|
5646 |
|
5647 |
|
5648 |
|
5649 |
|
5650 |
|
5651 |
|
5652 |
|
5653 | function getTarget() {
|
5654 | var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.event;
|
5655 |
|
5656 |
|
5657 | var target = null;
|
5658 | if (!event) ;else if (event.target) {
|
5659 | target = event.target;
|
5660 | } else if (event.srcElement) {
|
5661 | target = event.srcElement;
|
5662 | }
|
5663 |
|
5664 | if (!(target instanceof Element)) {
|
5665 | return null;
|
5666 | }
|
5667 |
|
5668 | if (target.nodeType != null && target.nodeType == 3) {
|
5669 |
|
5670 | target = target.parentNode;
|
5671 |
|
5672 | if (!(target instanceof Element)) {
|
5673 | return null;
|
5674 | }
|
5675 | }
|
5676 |
|
5677 | return target;
|
5678 | }
|
5679 |
|
5680 |
|
5681 |
|
5682 |
|
5683 |
|
5684 |
|
5685 |
|
5686 |
|
5687 |
|
5688 |
|
5689 | function hasParent(element, parent) {
|
5690 | var elem = element;
|
5691 |
|
5692 | while (elem) {
|
5693 | if (elem === parent) {
|
5694 | return true;
|
5695 | } else if (elem.parentNode) {
|
5696 | elem = elem.parentNode;
|
5697 | } else {
|
5698 | return false;
|
5699 | }
|
5700 | }
|
5701 |
|
5702 | return false;
|
5703 | }
|
5704 |
|
5705 | var option = {
|
5706 | |
5707 |
|
5708 |
|
5709 |
|
5710 |
|
5711 |
|
5712 |
|
5713 |
|
5714 | asBoolean: function asBoolean(value, defaultValue) {
|
5715 | if (typeof value == 'function') {
|
5716 | value = value();
|
5717 | }
|
5718 |
|
5719 | if (value != null) {
|
5720 | return value != false;
|
5721 | }
|
5722 |
|
5723 | return defaultValue || null;
|
5724 | },
|
5725 |
|
5726 | |
5727 |
|
5728 |
|
5729 |
|
5730 |
|
5731 |
|
5732 |
|
5733 |
|
5734 | asNumber: function asNumber(value, defaultValue) {
|
5735 | if (typeof value == 'function') {
|
5736 | value = value();
|
5737 | }
|
5738 |
|
5739 | if (value != null) {
|
5740 | return Number(value) || defaultValue || null;
|
5741 | }
|
5742 |
|
5743 | return defaultValue || null;
|
5744 | },
|
5745 |
|
5746 | |
5747 |
|
5748 |
|
5749 |
|
5750 |
|
5751 |
|
5752 |
|
5753 |
|
5754 | asString: function asString(value, defaultValue) {
|
5755 | if (typeof value == 'function') {
|
5756 | value = value();
|
5757 | }
|
5758 |
|
5759 | if (value != null) {
|
5760 | return String(value);
|
5761 | }
|
5762 |
|
5763 | return defaultValue || null;
|
5764 | },
|
5765 |
|
5766 | |
5767 |
|
5768 |
|
5769 |
|
5770 |
|
5771 |
|
5772 |
|
5773 |
|
5774 | asSize: function asSize(value, defaultValue) {
|
5775 | if (typeof value == 'function') {
|
5776 | value = value();
|
5777 | }
|
5778 |
|
5779 | if (isString(value)) {
|
5780 | return value;
|
5781 | } else if (isNumber(value)) {
|
5782 | return value + 'px';
|
5783 | } else {
|
5784 | return defaultValue || null;
|
5785 | }
|
5786 | },
|
5787 |
|
5788 | |
5789 |
|
5790 |
|
5791 |
|
5792 |
|
5793 |
|
5794 |
|
5795 |
|
5796 | asElement: function asElement(value, defaultValue) {
|
5797 | if (typeof value == 'function') {
|
5798 | value = value();
|
5799 | }
|
5800 |
|
5801 | return value || defaultValue || null;
|
5802 | }
|
5803 | };
|
5804 |
|
5805 |
|
5806 |
|
5807 |
|
5808 |
|
5809 |
|
5810 |
|
5811 |
|
5812 |
|
5813 | function hexToRGB(hex) {
|
5814 | var result;
|
5815 |
|
5816 | switch (hex.length) {
|
5817 | case 3:
|
5818 | case 4:
|
5819 | result = shortHexRE.exec(hex);
|
5820 | return result ? {
|
5821 | r: parseInt(result[1] + result[1], 16),
|
5822 | g: parseInt(result[2] + result[2], 16),
|
5823 | b: parseInt(result[3] + result[3], 16)
|
5824 | } : null;
|
5825 |
|
5826 | case 6:
|
5827 | case 7:
|
5828 | result = fullHexRE.exec(hex);
|
5829 | return result ? {
|
5830 | r: parseInt(result[1], 16),
|
5831 | g: parseInt(result[2], 16),
|
5832 | b: parseInt(result[3], 16)
|
5833 | } : null;
|
5834 |
|
5835 | default:
|
5836 | return null;
|
5837 | }
|
5838 | }
|
5839 |
|
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 |
|
5849 | function overrideOpacity(color, opacity) {
|
5850 | if (color.indexOf('rgba') !== -1) {
|
5851 | return color;
|
5852 | } else if (color.indexOf('rgb') !== -1) {
|
5853 | var rgb = color.substr(color.indexOf('(') + 1).replace(')', '').split(',');
|
5854 | return 'rgba(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ',' + opacity + ')';
|
5855 | } else {
|
5856 | var _rgb = hexToRGB(color);
|
5857 |
|
5858 | if (_rgb == null) {
|
5859 | return color;
|
5860 | } else {
|
5861 | return 'rgba(' + _rgb.r + ',' + _rgb.g + ',' + _rgb.b + ',' + opacity + ')';
|
5862 | }
|
5863 | }
|
5864 | }
|
5865 |
|
5866 |
|
5867 |
|
5868 |
|
5869 |
|
5870 |
|
5871 |
|
5872 |
|
5873 |
|
5874 |
|
5875 |
|
5876 | function RGBToHex(red, green, blue) {
|
5877 | return '#' + ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1);
|
5878 | }
|
5879 |
|
5880 |
|
5881 |
|
5882 |
|
5883 |
|
5884 |
|
5885 |
|
5886 |
|
5887 |
|
5888 |
|
5889 | function parseColor(inputColor, defaultColor) {
|
5890 | if (isString(inputColor)) {
|
5891 | var colorStr = inputColor;
|
5892 |
|
5893 | if (isValidRGB(colorStr)) {
|
5894 | var rgb = colorStr.substr(4).substr(0, colorStr.length - 5).split(',').map(function (value) {
|
5895 | return parseInt(value);
|
5896 | });
|
5897 | colorStr = RGBToHex(rgb[0], rgb[1], rgb[2]);
|
5898 | }
|
5899 |
|
5900 | if (isValidHex(colorStr) === true) {
|
5901 | var hsv = hexToHSV(colorStr);
|
5902 | var lighterColorHSV = {
|
5903 | h: hsv.h,
|
5904 | s: hsv.s * 0.8,
|
5905 | v: Math.min(1, hsv.v * 1.02)
|
5906 | };
|
5907 | var darkerColorHSV = {
|
5908 | h: hsv.h,
|
5909 | s: Math.min(1, hsv.s * 1.25),
|
5910 | v: hsv.v * 0.8
|
5911 | };
|
5912 | var darkerColorHex = HSVToHex(darkerColorHSV.h, darkerColorHSV.s, darkerColorHSV.v);
|
5913 | var lighterColorHex = HSVToHex(lighterColorHSV.h, lighterColorHSV.s, lighterColorHSV.v);
|
5914 | return {
|
5915 | background: colorStr,
|
5916 | border: darkerColorHex,
|
5917 | highlight: {
|
5918 | background: lighterColorHex,
|
5919 | border: darkerColorHex
|
5920 | },
|
5921 | hover: {
|
5922 | background: lighterColorHex,
|
5923 | border: darkerColorHex
|
5924 | }
|
5925 | };
|
5926 | } else {
|
5927 | return {
|
5928 | background: colorStr,
|
5929 | border: colorStr,
|
5930 | highlight: {
|
5931 | background: colorStr,
|
5932 | border: colorStr
|
5933 | },
|
5934 | hover: {
|
5935 | background: colorStr,
|
5936 | border: colorStr
|
5937 | }
|
5938 | };
|
5939 | }
|
5940 | } else {
|
5941 | if (defaultColor) {
|
5942 | var color = {
|
5943 | background: inputColor.background || defaultColor.background,
|
5944 | border: inputColor.border || defaultColor.border,
|
5945 | highlight: isString(inputColor.highlight) ? {
|
5946 | border: inputColor.highlight,
|
5947 | background: inputColor.highlight
|
5948 | } : {
|
5949 | background: inputColor.highlight && inputColor.highlight.background || defaultColor.highlight.background,
|
5950 | border: inputColor.highlight && inputColor.highlight.border || defaultColor.highlight.border
|
5951 | },
|
5952 | hover: isString(inputColor.hover) ? {
|
5953 | border: inputColor.hover,
|
5954 | background: inputColor.hover
|
5955 | } : {
|
5956 | border: inputColor.hover && inputColor.hover.border || defaultColor.hover.border,
|
5957 | background: inputColor.hover && inputColor.hover.background || defaultColor.hover.background
|
5958 | }
|
5959 | };
|
5960 | return color;
|
5961 | } else {
|
5962 | var _color = {
|
5963 | background: inputColor.background || undefined,
|
5964 | border: inputColor.border || undefined,
|
5965 | highlight: isString(inputColor.highlight) ? {
|
5966 | border: inputColor.highlight,
|
5967 | background: inputColor.highlight
|
5968 | } : {
|
5969 | background: inputColor.highlight && inputColor.highlight.background || undefined,
|
5970 | border: inputColor.highlight && inputColor.highlight.border || undefined
|
5971 | },
|
5972 | hover: isString(inputColor.hover) ? {
|
5973 | border: inputColor.hover,
|
5974 | background: inputColor.hover
|
5975 | } : {
|
5976 | border: inputColor.hover && inputColor.hover.border || undefined,
|
5977 | background: inputColor.hover && inputColor.hover.background || undefined
|
5978 | }
|
5979 | };
|
5980 | return _color;
|
5981 | }
|
5982 | }
|
5983 | }
|
5984 |
|
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 |
|
5990 |
|
5991 |
|
5992 |
|
5993 |
|
5994 |
|
5995 |
|
5996 | function RGBToHSV(red, green, blue) {
|
5997 | red = red / 255;
|
5998 | green = green / 255;
|
5999 | blue = blue / 255;
|
6000 | var minRGB = Math.min(red, Math.min(green, blue));
|
6001 | var maxRGB = Math.max(red, Math.max(green, blue));
|
6002 |
|
6003 | if (minRGB === maxRGB) {
|
6004 | return {
|
6005 | h: 0,
|
6006 | s: 0,
|
6007 | v: minRGB
|
6008 | };
|
6009 | }
|
6010 |
|
6011 |
|
6012 | var d = red === minRGB ? green - blue : blue === minRGB ? red - green : blue - red;
|
6013 | var h = red === minRGB ? 3 : blue === minRGB ? 1 : 5;
|
6014 | var hue = 60 * (h - d / (maxRGB - minRGB)) / 360;
|
6015 | var saturation = (maxRGB - minRGB) / maxRGB;
|
6016 | var value = maxRGB;
|
6017 | return {
|
6018 | h: hue,
|
6019 | s: saturation,
|
6020 | v: value
|
6021 | };
|
6022 | }
|
6023 |
|
6024 | var cssUtil = {
|
6025 |
|
6026 | split: function split(cssText) {
|
6027 | var styles = {};
|
6028 | cssText.split(';').forEach(function (style) {
|
6029 | if (style.trim() != '') {
|
6030 | var parts = style.split(':');
|
6031 |
|
6032 | var _key2 = parts[0].trim();
|
6033 |
|
6034 | var _value2 = parts[1].trim();
|
6035 |
|
6036 | styles[_key2] = _value2;
|
6037 | }
|
6038 | });
|
6039 | return styles;
|
6040 | },
|
6041 |
|
6042 | join: function join(styles) {
|
6043 | return Object.keys(styles).map(function (key) {
|
6044 | return key + ': ' + styles[key];
|
6045 | }).join('; ');
|
6046 | }
|
6047 | };
|
6048 |
|
6049 |
|
6050 |
|
6051 |
|
6052 |
|
6053 |
|
6054 |
|
6055 | function addCssText(element, cssText) {
|
6056 | var currentStyles = cssUtil.split(element.style.cssText);
|
6057 | var newStyles = cssUtil.split(cssText);
|
6058 |
|
6059 | var styles = _objectSpread2({}, currentStyles, {}, newStyles);
|
6060 |
|
6061 | element.style.cssText = cssUtil.join(styles);
|
6062 | }
|
6063 |
|
6064 |
|
6065 |
|
6066 |
|
6067 |
|
6068 |
|
6069 |
|
6070 |
|
6071 | function removeCssText(element, cssText) {
|
6072 | var styles = cssUtil.split(element.style.cssText);
|
6073 | var removeStyles = cssUtil.split(cssText);
|
6074 |
|
6075 | for (var _key3 in removeStyles) {
|
6076 | if (Object.prototype.hasOwnProperty.call(removeStyles, _key3)) {
|
6077 | delete styles[_key3];
|
6078 | }
|
6079 | }
|
6080 |
|
6081 | element.style.cssText = cssUtil.join(styles);
|
6082 | }
|
6083 |
|
6084 |
|
6085 |
|
6086 |
|
6087 |
|
6088 |
|
6089 |
|
6090 |
|
6091 |
|
6092 |
|
6093 |
|
6094 |
|
6095 | function HSVToRGB(h, s, v) {
|
6096 | var r;
|
6097 | var g;
|
6098 | var b;
|
6099 | var i = Math.floor(h * 6);
|
6100 | var f = h * 6 - i;
|
6101 | var p = v * (1 - s);
|
6102 | var q = v * (1 - f * s);
|
6103 | var t = v * (1 - (1 - f) * s);
|
6104 |
|
6105 | switch (i % 6) {
|
6106 | case 0:
|
6107 | r = v, g = t, b = p;
|
6108 | break;
|
6109 |
|
6110 | case 1:
|
6111 | r = q, g = v, b = p;
|
6112 | break;
|
6113 |
|
6114 | case 2:
|
6115 | r = p, g = v, b = t;
|
6116 | break;
|
6117 |
|
6118 | case 3:
|
6119 | r = p, g = q, b = v;
|
6120 | break;
|
6121 |
|
6122 | case 4:
|
6123 | r = t, g = p, b = v;
|
6124 | break;
|
6125 |
|
6126 | case 5:
|
6127 | r = v, g = p, b = q;
|
6128 | break;
|
6129 | }
|
6130 |
|
6131 | return {
|
6132 | r: Math.floor(r * 255),
|
6133 | g: Math.floor(g * 255),
|
6134 | b: Math.floor(b * 255)
|
6135 | };
|
6136 | }
|
6137 |
|
6138 |
|
6139 |
|
6140 |
|
6141 |
|
6142 |
|
6143 |
|
6144 |
|
6145 |
|
6146 |
|
6147 |
|
6148 | function HSVToHex(h, s, v) {
|
6149 | var rgb = HSVToRGB(h, s, v);
|
6150 | return RGBToHex(rgb.r, rgb.g, rgb.b);
|
6151 | }
|
6152 |
|
6153 |
|
6154 |
|
6155 |
|
6156 |
|
6157 |
|
6158 |
|
6159 |
|
6160 |
|
6161 | function hexToHSV(hex) {
|
6162 | var rgb = hexToRGB(hex);
|
6163 |
|
6164 | if (!rgb) {
|
6165 | throw new TypeError("'".concat(hex, "' is not a valid color."));
|
6166 | }
|
6167 |
|
6168 | return RGBToHSV(rgb.r, rgb.g, rgb.b);
|
6169 | }
|
6170 |
|
6171 |
|
6172 |
|
6173 |
|
6174 |
|
6175 |
|
6176 |
|
6177 |
|
6178 |
|
6179 | function isValidHex(hex) {
|
6180 | var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
|
6181 | return isOk;
|
6182 | }
|
6183 |
|
6184 |
|
6185 |
|
6186 |
|
6187 |
|
6188 |
|
6189 |
|
6190 |
|
6191 |
|
6192 | function isValidRGB(rgb) {
|
6193 | rgb = rgb.replace(' ', '');
|
6194 | var isOk = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(rgb);
|
6195 | return isOk;
|
6196 | }
|
6197 |
|
6198 |
|
6199 |
|
6200 |
|
6201 |
|
6202 |
|
6203 |
|
6204 |
|
6205 |
|
6206 | function isValidRGBA(rgba) {
|
6207 | rgba = rgba.replace(' ', '');
|
6208 | var isOk = /rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(0?.{1,3})\)/i.test(rgba);
|
6209 | return isOk;
|
6210 | }
|
6211 |
|
6212 |
|
6213 |
|
6214 |
|
6215 |
|
6216 |
|
6217 |
|
6218 |
|
6219 |
|
6220 |
|
6221 |
|
6222 | function selectiveBridgeObject(fields, referenceObject) {
|
6223 | if (referenceObject !== null && _typeof(referenceObject) === 'object') {
|
6224 |
|
6225 | var objectTo = Object.create(referenceObject);
|
6226 |
|
6227 | for (var i = 0; i < fields.length; i++) {
|
6228 | if (Object.prototype.hasOwnProperty.call(referenceObject, fields[i])) {
|
6229 | if (_typeof(referenceObject[fields[i]]) == 'object') {
|
6230 | objectTo[fields[i]] = bridgeObject(referenceObject[fields[i]]);
|
6231 | }
|
6232 | }
|
6233 | }
|
6234 |
|
6235 | return objectTo;
|
6236 | } else {
|
6237 | return null;
|
6238 | }
|
6239 | }
|
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 |
|
6245 |
|
6246 |
|
6247 |
|
6248 |
|
6249 |
|
6250 | function bridgeObject(referenceObject) {
|
6251 | if (referenceObject === null || _typeof(referenceObject) !== 'object') {
|
6252 | return null;
|
6253 | }
|
6254 |
|
6255 | if (referenceObject instanceof Element) {
|
6256 |
|
6257 | return referenceObject;
|
6258 | }
|
6259 |
|
6260 | var objectTo = Object.create(referenceObject);
|
6261 |
|
6262 | for (var i in referenceObject) {
|
6263 | if (Object.prototype.hasOwnProperty.call(referenceObject, i)) {
|
6264 | if (_typeof(referenceObject[i]) == 'object') {
|
6265 | objectTo[i] = bridgeObject(referenceObject[i]);
|
6266 | }
|
6267 | }
|
6268 | }
|
6269 |
|
6270 | return objectTo;
|
6271 | }
|
6272 |
|
6273 |
|
6274 |
|
6275 |
|
6276 |
|
6277 |
|
6278 |
|
6279 |
|
6280 |
|
6281 |
|
6282 | function insertSort(a, compare) {
|
6283 | for (var i = 0; i < a.length; i++) {
|
6284 | var k = a[i];
|
6285 | var j = void 0;
|
6286 |
|
6287 | for (j = i; j > 0 && compare(k, a[j - 1]) < 0; j--) {
|
6288 | a[j] = a[j - 1];
|
6289 | }
|
6290 |
|
6291 | a[j] = k;
|
6292 | }
|
6293 |
|
6294 | return a;
|
6295 | }
|
6296 |
|
6297 |
|
6298 |
|
6299 |
|
6300 |
|
6301 |
|
6302 |
|
6303 |
|
6304 |
|
6305 |
|
6306 |
|
6307 |
|
6308 |
|
6309 |
|
6310 |
|
6311 | function mergeOptions(mergeTarget, options, option) {
|
6312 | var globalOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
6313 |
|
6314 | var isPresent = function isPresent(obj) {
|
6315 | return obj !== null && obj !== undefined;
|
6316 | };
|
6317 |
|
6318 | var isObject = function isObject(obj) {
|
6319 | return obj !== null && _typeof(obj) === 'object';
|
6320 | };
|
6321 |
|
6322 |
|
6323 | var isEmpty = function isEmpty(obj) {
|
6324 | for (var x in obj) {
|
6325 | if (Object.prototype.hasOwnProperty.call(obj, x)) {
|
6326 | return false;
|
6327 | }
|
6328 | }
|
6329 |
|
6330 | return true;
|
6331 | };
|
6332 |
|
6333 |
|
6334 | if (!isObject(mergeTarget)) {
|
6335 | throw new Error('Parameter mergeTarget must be an object');
|
6336 | }
|
6337 |
|
6338 | if (!isObject(options)) {
|
6339 | throw new Error('Parameter options must be an object');
|
6340 | }
|
6341 |
|
6342 | if (!isPresent(option)) {
|
6343 | throw new Error('Parameter option must have a value');
|
6344 | }
|
6345 |
|
6346 | if (!isObject(globalOptions)) {
|
6347 | throw new Error('Parameter globalOptions must be an object');
|
6348 | }
|
6349 |
|
6350 |
|
6351 |
|
6352 |
|
6353 |
|
6354 | var doMerge = function doMerge(target, options, option) {
|
6355 | if (!isObject(target[option])) {
|
6356 | target[option] = {};
|
6357 | }
|
6358 |
|
6359 | var src = options[option];
|
6360 | var dst = target[option];
|
6361 |
|
6362 | for (var prop in src) {
|
6363 | if (Object.prototype.hasOwnProperty.call(src, prop)) {
|
6364 | dst[prop] = src[prop];
|
6365 | }
|
6366 | }
|
6367 | };
|
6368 |
|
6369 |
|
6370 | var srcOption = options[option];
|
6371 | var globalPassed = isObject(globalOptions) && !isEmpty(globalOptions);
|
6372 | var globalOption = globalPassed ? globalOptions[option] : undefined;
|
6373 | var globalEnabled = globalOption ? globalOption.enabled : undefined;
|
6374 |
|
6375 |
|
6376 |
|
6377 | if (srcOption === undefined) {
|
6378 | return;
|
6379 | }
|
6380 |
|
6381 | if (typeof srcOption === 'boolean') {
|
6382 | if (!isObject(mergeTarget[option])) {
|
6383 | mergeTarget[option] = {};
|
6384 | }
|
6385 |
|
6386 | mergeTarget[option].enabled = srcOption;
|
6387 | return;
|
6388 | }
|
6389 |
|
6390 | if (srcOption === null && !isObject(mergeTarget[option])) {
|
6391 |
|
6392 | if (isPresent(globalOption)) {
|
6393 | mergeTarget[option] = Object.create(globalOption);
|
6394 | } else {
|
6395 | return;
|
6396 | }
|
6397 | }
|
6398 |
|
6399 | if (!isObject(srcOption)) {
|
6400 | return;
|
6401 | }
|
6402 |
|
6403 |
|
6404 |
|
6405 |
|
6406 |
|
6407 | var enabled = true;
|
6408 |
|
6409 | if (srcOption.enabled !== undefined) {
|
6410 | enabled = srcOption.enabled;
|
6411 | } else {
|
6412 |
|
6413 | if (globalEnabled !== undefined) {
|
6414 | enabled = globalOption.enabled;
|
6415 | }
|
6416 | }
|
6417 |
|
6418 | doMerge(mergeTarget, options, option);
|
6419 | mergeTarget[option].enabled = enabled;
|
6420 | }
|
6421 |
|
6422 |
|
6423 |
|
6424 |
|
6425 |
|
6426 |
|
6427 |
|
6428 |
|
6429 |
|
6430 |
|
6431 |
|
6432 |
|
6433 |
|
6434 | function binarySearchCustom(orderedItems, comparator, field, field2) {
|
6435 | var maxIterations = 10000;
|
6436 | var iteration = 0;
|
6437 | var low = 0;
|
6438 | var high = orderedItems.length - 1;
|
6439 |
|
6440 | while (low <= high && iteration < maxIterations) {
|
6441 | var middle = Math.floor((low + high) / 2);
|
6442 | var item = orderedItems[middle];
|
6443 |
|
6444 | var _value3 = field2 === undefined ? item[field] : item[field][field2];
|
6445 |
|
6446 | var searchResult = comparator(_value3);
|
6447 |
|
6448 | if (searchResult == 0) {
|
6449 |
|
6450 | return middle;
|
6451 | } else if (searchResult == -1) {
|
6452 |
|
6453 | low = middle + 1;
|
6454 | } else {
|
6455 |
|
6456 | high = middle - 1;
|
6457 | }
|
6458 |
|
6459 | iteration++;
|
6460 | }
|
6461 |
|
6462 | return -1;
|
6463 | }
|
6464 |
|
6465 |
|
6466 |
|
6467 |
|
6468 |
|
6469 |
|
6470 |
|
6471 |
|
6472 |
|
6473 |
|
6474 |
|
6475 |
|
6476 |
|
6477 |
|
6478 |
|
6479 | function binarySearchValue(orderedItems, target, field, sidePreference, comparator) {
|
6480 | var maxIterations = 10000;
|
6481 | var iteration = 0;
|
6482 | var low = 0;
|
6483 | var high = orderedItems.length - 1;
|
6484 | var prevValue;
|
6485 | var value;
|
6486 | var nextValue;
|
6487 | var middle;
|
6488 | comparator = comparator != undefined ? comparator : function (a, b) {
|
6489 | return a == b ? 0 : a < b ? -1 : 1;
|
6490 | };
|
6491 |
|
6492 | while (low <= high && iteration < maxIterations) {
|
6493 |
|
6494 | middle = Math.floor(0.5 * (high + low));
|
6495 | prevValue = orderedItems[Math.max(0, middle - 1)][field];
|
6496 | value = orderedItems[middle][field];
|
6497 | nextValue = orderedItems[Math.min(orderedItems.length - 1, middle + 1)][field];
|
6498 |
|
6499 | if (comparator(value, target) == 0) {
|
6500 |
|
6501 | return middle;
|
6502 | } else if (comparator(prevValue, target) < 0 && comparator(value, target) > 0) {
|
6503 |
|
6504 | return sidePreference == 'before' ? Math.max(0, middle - 1) : middle;
|
6505 | } else if (comparator(value, target) < 0 && comparator(nextValue, target) > 0) {
|
6506 |
|
6507 | return sidePreference == 'before' ? middle : Math.min(orderedItems.length - 1, middle + 1);
|
6508 | } else {
|
6509 |
|
6510 | if (comparator(value, target) < 0) {
|
6511 |
|
6512 | low = middle + 1;
|
6513 | } else {
|
6514 |
|
6515 | high = middle - 1;
|
6516 | }
|
6517 | }
|
6518 |
|
6519 | iteration++;
|
6520 | }
|
6521 |
|
6522 |
|
6523 | return -1;
|
6524 | }
|
6525 |
|
6526 |
|
6527 |
|
6528 |
|
6529 |
|
6530 |
|
6531 |
|
6532 |
|
6533 |
|
6534 | var easingFunctions = {
|
6535 | |
6536 |
|
6537 |
|
6538 |
|
6539 |
|
6540 |
|
6541 |
|
6542 | linear: function linear(t) {
|
6543 | return t;
|
6544 | },
|
6545 |
|
6546 | |
6547 |
|
6548 |
|
6549 |
|
6550 |
|
6551 |
|
6552 |
|
6553 | easeInQuad: function easeInQuad(t) {
|
6554 | return t * t;
|
6555 | },
|
6556 |
|
6557 | |
6558 |
|
6559 |
|
6560 |
|
6561 |
|
6562 |
|
6563 |
|
6564 | easeOutQuad: function easeOutQuad(t) {
|
6565 | return t * (2 - t);
|
6566 | },
|
6567 |
|
6568 | |
6569 |
|
6570 |
|
6571 |
|
6572 |
|
6573 |
|
6574 |
|
6575 | easeInOutQuad: function easeInOutQuad(t) {
|
6576 | return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
6577 | },
|
6578 |
|
6579 | |
6580 |
|
6581 |
|
6582 |
|
6583 |
|
6584 |
|
6585 |
|
6586 | easeInCubic: function easeInCubic(t) {
|
6587 | return t * t * t;
|
6588 | },
|
6589 |
|
6590 | |
6591 |
|
6592 |
|
6593 |
|
6594 |
|
6595 |
|
6596 |
|
6597 | easeOutCubic: function easeOutCubic(t) {
|
6598 | return --t * t * t + 1;
|
6599 | },
|
6600 |
|
6601 | |
6602 |
|
6603 |
|
6604 |
|
6605 |
|
6606 |
|
6607 |
|
6608 | easeInOutCubic: function easeInOutCubic(t) {
|
6609 | return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
6610 | },
|
6611 |
|
6612 | |
6613 |
|
6614 |
|
6615 |
|
6616 |
|
6617 |
|
6618 |
|
6619 | easeInQuart: function easeInQuart(t) {
|
6620 | return t * t * t * t;
|
6621 | },
|
6622 |
|
6623 | |
6624 |
|
6625 |
|
6626 |
|
6627 |
|
6628 |
|
6629 |
|
6630 | easeOutQuart: function easeOutQuart(t) {
|
6631 | return 1 - --t * t * t * t;
|
6632 | },
|
6633 |
|
6634 | |
6635 |
|
6636 |
|
6637 |
|
6638 |
|
6639 |
|
6640 |
|
6641 | easeInOutQuart: function easeInOutQuart(t) {
|
6642 | return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
6643 | },
|
6644 |
|
6645 | |
6646 |
|
6647 |
|
6648 |
|
6649 |
|
6650 |
|
6651 |
|
6652 | easeInQuint: function easeInQuint(t) {
|
6653 | return t * t * t * t * t;
|
6654 | },
|
6655 |
|
6656 | |
6657 |
|
6658 |
|
6659 |
|
6660 |
|
6661 |
|
6662 |
|
6663 | easeOutQuint: function easeOutQuint(t) {
|
6664 | return 1 + --t * t * t * t * t;
|
6665 | },
|
6666 |
|
6667 | |
6668 |
|
6669 |
|
6670 |
|
6671 |
|
6672 |
|
6673 |
|
6674 | easeInOutQuint: function easeInOutQuint(t) {
|
6675 | return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
6676 | }
|
6677 | };
|
6678 |
|
6679 |
|
6680 |
|
6681 |
|
6682 |
|
6683 |
|
6684 | function getScrollBarWidth() {
|
6685 | var inner = document.createElement('p');
|
6686 | inner.style.width = '100%';
|
6687 | inner.style.height = '200px';
|
6688 | var outer = document.createElement('div');
|
6689 | outer.style.position = 'absolute';
|
6690 | outer.style.top = '0px';
|
6691 | outer.style.left = '0px';
|
6692 | outer.style.visibility = 'hidden';
|
6693 | outer.style.width = '200px';
|
6694 | outer.style.height = '150px';
|
6695 | outer.style.overflow = 'hidden';
|
6696 | outer.appendChild(inner);
|
6697 | document.body.appendChild(outer);
|
6698 | var w1 = inner.offsetWidth;
|
6699 | outer.style.overflow = 'scroll';
|
6700 | var w2 = inner.offsetWidth;
|
6701 |
|
6702 | if (w1 == w2) {
|
6703 | w2 = outer.clientWidth;
|
6704 | }
|
6705 |
|
6706 | document.body.removeChild(outer);
|
6707 | return w1 - w2;
|
6708 | }
|
6709 |
|
6710 |
|
6711 |
|
6712 |
|
6713 |
|
6714 |
|
6715 |
|
6716 |
|
6717 |
|
6718 |
|
6719 |
|
6720 |
|
6721 |
|
6722 |
|
6723 |
|
6724 |
|
6725 |
|
6726 |
|
6727 |
|
6728 |
|
6729 |
|
6730 |
|
6731 |
|
6732 |
|
6733 |
|
6734 | function topMost(pile, accessors) {
|
6735 | var candidate;
|
6736 |
|
6737 | if (!Array.isArray(accessors)) {
|
6738 | accessors = [accessors];
|
6739 | }
|
6740 |
|
6741 | var _iteratorNormalCompletion = true;
|
6742 | var _didIteratorError = false;
|
6743 | var _iteratorError = undefined;
|
6744 |
|
6745 | try {
|
6746 | for (var _iterator = pile[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
6747 | var member = _step.value;
|
6748 |
|
6749 | if (member) {
|
6750 | candidate = member[accessors[0]];
|
6751 |
|
6752 | for (var i = 1; i < accessors.length; i++) {
|
6753 | if (candidate) {
|
6754 | candidate = candidate[accessors[i]];
|
6755 | }
|
6756 | }
|
6757 |
|
6758 | if (typeof candidate !== 'undefined') {
|
6759 | break;
|
6760 | }
|
6761 | }
|
6762 | }
|
6763 | } catch (err) {
|
6764 | _didIteratorError = true;
|
6765 | _iteratorError = err;
|
6766 | } finally {
|
6767 | try {
|
6768 | if (!_iteratorNormalCompletion && _iterator.return != null) {
|
6769 | _iterator.return();
|
6770 | }
|
6771 | } finally {
|
6772 | if (_didIteratorError) {
|
6773 | throw _iteratorError;
|
6774 | }
|
6775 | }
|
6776 | }
|
6777 |
|
6778 | return candidate;
|
6779 | }
|
6780 |
|
6781 | var util =
|
6782 |
|
6783 | Object.freeze({
|
6784 | isNumber: isNumber,
|
6785 | recursiveDOMDelete: recursiveDOMDelete,
|
6786 | isString: isString,
|
6787 | isObject: isObject,
|
6788 | isDate: isDate,
|
6789 | isMoment: isMoment,
|
6790 | fillIfDefined: fillIfDefined,
|
6791 | extend: extend,
|
6792 | selectiveExtend: selectiveExtend,
|
6793 | selectiveDeepExtend: selectiveDeepExtend,
|
6794 | selectiveNotDeepExtend: selectiveNotDeepExtend,
|
6795 | deepExtend: deepExtend,
|
6796 | equalArray: equalArray,
|
6797 | convert: convert,
|
6798 | getType: getType,
|
6799 | copyAndExtendArray: copyAndExtendArray,
|
6800 | copyArray: copyArray,
|
6801 | getAbsoluteLeft: getAbsoluteLeft,
|
6802 | getAbsoluteRight: getAbsoluteRight,
|
6803 | getAbsoluteTop: getAbsoluteTop,
|
6804 | addClassName: addClassName,
|
6805 | removeClassName: removeClassName,
|
6806 | forEach: forEach,
|
6807 | toArray: toArray,
|
6808 | updateProperty: updateProperty,
|
6809 | throttle: throttle,
|
6810 | addEventListener: addEventListener,
|
6811 | removeEventListener: removeEventListener,
|
6812 | preventDefault: preventDefault,
|
6813 | getTarget: getTarget,
|
6814 | hasParent: hasParent,
|
6815 | option: option,
|
6816 | hexToRGB: hexToRGB,
|
6817 | overrideOpacity: overrideOpacity,
|
6818 | RGBToHex: RGBToHex,
|
6819 | parseColor: parseColor,
|
6820 | RGBToHSV: RGBToHSV,
|
6821 | addCssText: addCssText,
|
6822 | removeCssText: removeCssText,
|
6823 | HSVToRGB: HSVToRGB,
|
6824 | HSVToHex: HSVToHex,
|
6825 | hexToHSV: hexToHSV,
|
6826 | isValidHex: isValidHex,
|
6827 | isValidRGB: isValidRGB,
|
6828 | isValidRGBA: isValidRGBA,
|
6829 | selectiveBridgeObject: selectiveBridgeObject,
|
6830 | bridgeObject: bridgeObject,
|
6831 | insertSort: insertSort,
|
6832 | mergeOptions: mergeOptions,
|
6833 | binarySearchCustom: binarySearchCustom,
|
6834 | binarySearchValue: binarySearchValue,
|
6835 | easingFunctions: easingFunctions,
|
6836 | getScrollBarWidth: getScrollBarWidth,
|
6837 | topMost: topMost,
|
6838 | randomUUID: uuid4
|
6839 | });
|
6840 |
|
6841 | var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
6842 |
|
6843 | function commonjsRequire$1 () {
|
6844 | throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
6845 | }
|
6846 |
|
6847 | function createCommonjsModule$1(fn, module) {
|
6848 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
6849 | }
|
6850 |
|
6851 | var DOMutil = createCommonjsModule$1(function (module, exports) {
|
6852 |
|
6853 |
|
6854 | |
6855 |
|
6856 |
|
6857 |
|
6858 |
|
6859 | exports.prepareElements = function (JSONcontainer) {
|
6860 |
|
6861 | for (var elementType in JSONcontainer) {
|
6862 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
6863 | JSONcontainer[elementType].redundant = JSONcontainer[elementType].used;
|
6864 | JSONcontainer[elementType].used = [];
|
6865 | }
|
6866 | }
|
6867 | };
|
6868 | |
6869 |
|
6870 |
|
6871 |
|
6872 |
|
6873 |
|
6874 |
|
6875 |
|
6876 |
|
6877 | exports.cleanupElements = function (JSONcontainer) {
|
6878 |
|
6879 | for (var elementType in JSONcontainer) {
|
6880 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
6881 | if (JSONcontainer[elementType].redundant) {
|
6882 | for (var i = 0; i < JSONcontainer[elementType].redundant.length; i++) {
|
6883 | JSONcontainer[elementType].redundant[i].parentNode.removeChild(JSONcontainer[elementType].redundant[i]);
|
6884 | }
|
6885 |
|
6886 | JSONcontainer[elementType].redundant = [];
|
6887 | }
|
6888 | }
|
6889 | }
|
6890 | };
|
6891 | |
6892 |
|
6893 |
|
6894 |
|
6895 |
|
6896 |
|
6897 | exports.resetElements = function (JSONcontainer) {
|
6898 | exports.prepareElements(JSONcontainer);
|
6899 | exports.cleanupElements(JSONcontainer);
|
6900 | exports.prepareElements(JSONcontainer);
|
6901 | };
|
6902 | |
6903 |
|
6904 |
|
6905 |
|
6906 |
|
6907 |
|
6908 |
|
6909 |
|
6910 |
|
6911 |
|
6912 |
|
6913 |
|
6914 | exports.getSVGElement = function (elementType, JSONcontainer, svgContainer) {
|
6915 | var element;
|
6916 |
|
6917 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
6918 |
|
6919 |
|
6920 | if (JSONcontainer[elementType].redundant.length > 0) {
|
6921 | element = JSONcontainer[elementType].redundant[0];
|
6922 | JSONcontainer[elementType].redundant.shift();
|
6923 | } else {
|
6924 |
|
6925 | element = document.createElementNS('http://www.w3.org/2000/svg', elementType);
|
6926 | svgContainer.appendChild(element);
|
6927 | }
|
6928 | } else {
|
6929 |
|
6930 | element = document.createElementNS('http://www.w3.org/2000/svg', elementType);
|
6931 | JSONcontainer[elementType] = {
|
6932 | used: [],
|
6933 | redundant: []
|
6934 | };
|
6935 | svgContainer.appendChild(element);
|
6936 | }
|
6937 |
|
6938 | JSONcontainer[elementType].used.push(element);
|
6939 | return element;
|
6940 | };
|
6941 | |
6942 |
|
6943 |
|
6944 |
|
6945 |
|
6946 |
|
6947 |
|
6948 |
|
6949 |
|
6950 |
|
6951 |
|
6952 |
|
6953 | exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer, insertBefore) {
|
6954 | var element;
|
6955 |
|
6956 | if (JSONcontainer.hasOwnProperty(elementType)) {
|
6957 |
|
6958 |
|
6959 | if (JSONcontainer[elementType].redundant.length > 0) {
|
6960 | element = JSONcontainer[elementType].redundant[0];
|
6961 | JSONcontainer[elementType].redundant.shift();
|
6962 | } else {
|
6963 |
|
6964 | element = document.createElement(elementType);
|
6965 |
|
6966 | if (insertBefore !== undefined) {
|
6967 | DOMContainer.insertBefore(element, insertBefore);
|
6968 | } else {
|
6969 | DOMContainer.appendChild(element);
|
6970 | }
|
6971 | }
|
6972 | } else {
|
6973 |
|
6974 | element = document.createElement(elementType);
|
6975 | JSONcontainer[elementType] = {
|
6976 | used: [],
|
6977 | redundant: []
|
6978 | };
|
6979 |
|
6980 | if (insertBefore !== undefined) {
|
6981 | DOMContainer.insertBefore(element, insertBefore);
|
6982 | } else {
|
6983 | DOMContainer.appendChild(element);
|
6984 | }
|
6985 | }
|
6986 |
|
6987 | JSONcontainer[elementType].used.push(element);
|
6988 | return element;
|
6989 | };
|
6990 | |
6991 |
|
6992 |
|
6993 |
|
6994 |
|
6995 |
|
6996 |
|
6997 |
|
6998 |
|
6999 |
|
7000 |
|
7001 |
|
7002 |
|
7003 |
|
7004 |
|
7005 | exports.drawPoint = function (x, y, groupTemplate, JSONcontainer, svgContainer, labelObj) {
|
7006 | var point;
|
7007 |
|
7008 | if (groupTemplate.style == 'circle') {
|
7009 | point = exports.getSVGElement('circle', JSONcontainer, svgContainer);
|
7010 | point.setAttributeNS(null, "cx", x);
|
7011 | point.setAttributeNS(null, "cy", y);
|
7012 | point.setAttributeNS(null, "r", 0.5 * groupTemplate.size);
|
7013 | } else {
|
7014 | point = exports.getSVGElement('rect', JSONcontainer, svgContainer);
|
7015 | point.setAttributeNS(null, "x", x - 0.5 * groupTemplate.size);
|
7016 | point.setAttributeNS(null, "y", y - 0.5 * groupTemplate.size);
|
7017 | point.setAttributeNS(null, "width", groupTemplate.size);
|
7018 | point.setAttributeNS(null, "height", groupTemplate.size);
|
7019 | }
|
7020 |
|
7021 | if (groupTemplate.styles !== undefined) {
|
7022 | point.setAttributeNS(null, "style", groupTemplate.styles);
|
7023 | }
|
7024 |
|
7025 | point.setAttributeNS(null, "class", groupTemplate.className + " vis-point");
|
7026 |
|
7027 | if (labelObj) {
|
7028 | var label = exports.getSVGElement('text', JSONcontainer, svgContainer);
|
7029 |
|
7030 | if (labelObj.xOffset) {
|
7031 | x = x + labelObj.xOffset;
|
7032 | }
|
7033 |
|
7034 | if (labelObj.yOffset) {
|
7035 | y = y + labelObj.yOffset;
|
7036 | }
|
7037 |
|
7038 | if (labelObj.content) {
|
7039 | label.textContent = labelObj.content;
|
7040 | }
|
7041 |
|
7042 | if (labelObj.className) {
|
7043 | label.setAttributeNS(null, "class", labelObj.className + " vis-label");
|
7044 | }
|
7045 |
|
7046 | label.setAttributeNS(null, "x", x);
|
7047 | label.setAttributeNS(null, "y", y);
|
7048 | }
|
7049 |
|
7050 | return point;
|
7051 | };
|
7052 | |
7053 |
|
7054 |
|
7055 |
|
7056 |
|
7057 |
|
7058 |
|
7059 |
|
7060 |
|
7061 |
|
7062 |
|
7063 |
|
7064 |
|
7065 |
|
7066 | exports.drawBar = function (x, y, width, height, className, JSONcontainer, svgContainer, style) {
|
7067 | if (height != 0) {
|
7068 | if (height < 0) {
|
7069 | height *= -1;
|
7070 | y -= height;
|
7071 | }
|
7072 |
|
7073 | var rect = exports.getSVGElement('rect', JSONcontainer, svgContainer);
|
7074 | rect.setAttributeNS(null, "x", x - 0.5 * width);
|
7075 | rect.setAttributeNS(null, "y", y);
|
7076 | rect.setAttributeNS(null, "width", width);
|
7077 | rect.setAttributeNS(null, "height", height);
|
7078 | rect.setAttributeNS(null, "class", className);
|
7079 |
|
7080 | if (style) {
|
7081 | rect.setAttributeNS(null, "style", style);
|
7082 | }
|
7083 | }
|
7084 | };
|
7085 | });
|
7086 | var DOMutil_1 = DOMutil.prepareElements;
|
7087 | var DOMutil_2 = DOMutil.cleanupElements;
|
7088 | var DOMutil_3 = DOMutil.resetElements;
|
7089 | var DOMutil_4 = DOMutil.getSVGElement;
|
7090 | var DOMutil_5 = DOMutil.getDOMElement;
|
7091 | var DOMutil_6 = DOMutil.drawPoint;
|
7092 | var DOMutil_7 = DOMutil.drawBar;
|
7093 |
|
7094 |
|
7095 |
|
7096 |
|
7097 |
|
7098 |
|
7099 |
|
7100 |
|
7101 |
|
7102 |
|
7103 |
|
7104 |
|
7105 |
|
7106 |
|
7107 |
|
7108 |
|
7109 |
|
7110 |
|
7111 |
|
7112 |
|
7113 |
|
7114 |
|
7115 |
|
7116 |
|
7117 |
|
7118 |
|
7119 | function _typeof$1(obj) {
|
7120 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
7121 | _typeof$1 = function (obj) {
|
7122 | return typeof obj;
|
7123 | };
|
7124 | } else {
|
7125 | _typeof$1 = function (obj) {
|
7126 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
7127 | };
|
7128 | }
|
7129 |
|
7130 | return _typeof$1(obj);
|
7131 | }
|
7132 |
|
7133 | var commonjsGlobal$2 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
7134 |
|
7135 | function commonjsRequire$2() {
|
7136 | throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
7137 | }
|
7138 |
|
7139 | function createCommonjsModule$2(fn, module) {
|
7140 | return module = {
|
7141 | exports: {}
|
7142 | }, fn(module, module.exports), module.exports;
|
7143 | }
|
7144 |
|
7145 | var moment$1 = createCommonjsModule$2(function (module, exports) {
|
7146 | (function (global, factory) {
|
7147 | module.exports = factory();
|
7148 | })(commonjsGlobal$2, function () {
|
7149 | var hookCallback;
|
7150 |
|
7151 | function hooks() {
|
7152 | return hookCallback.apply(null, arguments);
|
7153 | }
|
7154 |
|
7155 |
|
7156 |
|
7157 | function setHookCallback(callback) {
|
7158 | hookCallback = callback;
|
7159 | }
|
7160 |
|
7161 | function isArray(input) {
|
7162 | return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
7163 | }
|
7164 |
|
7165 | function isObject(input) {
|
7166 |
|
7167 |
|
7168 | return input != null && Object.prototype.toString.call(input) === '[object Object]';
|
7169 | }
|
7170 |
|
7171 | function isObjectEmpty(obj) {
|
7172 | if (Object.getOwnPropertyNames) {
|
7173 | return Object.getOwnPropertyNames(obj).length === 0;
|
7174 | } else {
|
7175 | var k;
|
7176 |
|
7177 | for (k in obj) {
|
7178 | if (obj.hasOwnProperty(k)) {
|
7179 | return false;
|
7180 | }
|
7181 | }
|
7182 |
|
7183 | return true;
|
7184 | }
|
7185 | }
|
7186 |
|
7187 | function isUndefined(input) {
|
7188 | return input === void 0;
|
7189 | }
|
7190 |
|
7191 | function isNumber(input) {
|
7192 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
7193 | }
|
7194 |
|
7195 | function isDate(input) {
|
7196 | return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
7197 | }
|
7198 |
|
7199 | function map(arr, fn) {
|
7200 | var res = [],
|
7201 | i;
|
7202 |
|
7203 | for (i = 0; i < arr.length; ++i) {
|
7204 | res.push(fn(arr[i], i));
|
7205 | }
|
7206 |
|
7207 | return res;
|
7208 | }
|
7209 |
|
7210 | function hasOwnProp(a, b) {
|
7211 | return Object.prototype.hasOwnProperty.call(a, b);
|
7212 | }
|
7213 |
|
7214 | function extend(a, b) {
|
7215 | for (var i in b) {
|
7216 | if (hasOwnProp(b, i)) {
|
7217 | a[i] = b[i];
|
7218 | }
|
7219 | }
|
7220 |
|
7221 | if (hasOwnProp(b, 'toString')) {
|
7222 | a.toString = b.toString;
|
7223 | }
|
7224 |
|
7225 | if (hasOwnProp(b, 'valueOf')) {
|
7226 | a.valueOf = b.valueOf;
|
7227 | }
|
7228 |
|
7229 | return a;
|
7230 | }
|
7231 |
|
7232 | function createUTC(input, format, locale, strict) {
|
7233 | return createLocalOrUTC(input, format, locale, strict, true).utc();
|
7234 | }
|
7235 |
|
7236 | function defaultParsingFlags() {
|
7237 |
|
7238 | return {
|
7239 | empty: false,
|
7240 | unusedTokens: [],
|
7241 | unusedInput: [],
|
7242 | overflow: -2,
|
7243 | charsLeftOver: 0,
|
7244 | nullInput: false,
|
7245 | invalidMonth: null,
|
7246 | invalidFormat: false,
|
7247 | userInvalidated: false,
|
7248 | iso: false,
|
7249 | parsedDateParts: [],
|
7250 | meridiem: null,
|
7251 | rfc2822: false,
|
7252 | weekdayMismatch: false
|
7253 | };
|
7254 | }
|
7255 |
|
7256 | function getParsingFlags(m) {
|
7257 | if (m._pf == null) {
|
7258 | m._pf = defaultParsingFlags();
|
7259 | }
|
7260 |
|
7261 | return m._pf;
|
7262 | }
|
7263 |
|
7264 | var some;
|
7265 |
|
7266 | if (Array.prototype.some) {
|
7267 | some = Array.prototype.some;
|
7268 | } else {
|
7269 | some = function (fun) {
|
7270 | var t = Object(this);
|
7271 | var len = t.length >>> 0;
|
7272 |
|
7273 | for (var i = 0; i < len; i++) {
|
7274 | if (i in t && fun.call(this, t[i], i, t)) {
|
7275 | return true;
|
7276 | }
|
7277 | }
|
7278 |
|
7279 | return false;
|
7280 | };
|
7281 | }
|
7282 |
|
7283 | function isValid(m) {
|
7284 | if (m._isValid == null) {
|
7285 | var flags = getParsingFlags(m);
|
7286 | var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
7287 | return i != null;
|
7288 | });
|
7289 | var isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || flags.meridiem && parsedParts);
|
7290 |
|
7291 | if (m._strict) {
|
7292 | isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === undefined;
|
7293 | }
|
7294 |
|
7295 | if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
7296 | m._isValid = isNowValid;
|
7297 | } else {
|
7298 | return isNowValid;
|
7299 | }
|
7300 | }
|
7301 |
|
7302 | return m._isValid;
|
7303 | }
|
7304 |
|
7305 | function createInvalid(flags) {
|
7306 | var m = createUTC(NaN);
|
7307 |
|
7308 | if (flags != null) {
|
7309 | extend(getParsingFlags(m), flags);
|
7310 | } else {
|
7311 | getParsingFlags(m).userInvalidated = true;
|
7312 | }
|
7313 |
|
7314 | return m;
|
7315 | }
|
7316 |
|
7317 |
|
7318 |
|
7319 | var momentProperties = hooks.momentProperties = [];
|
7320 |
|
7321 | function copyConfig(to, from) {
|
7322 | var i, prop, val;
|
7323 |
|
7324 | if (!isUndefined(from._isAMomentObject)) {
|
7325 | to._isAMomentObject = from._isAMomentObject;
|
7326 | }
|
7327 |
|
7328 | if (!isUndefined(from._i)) {
|
7329 | to._i = from._i;
|
7330 | }
|
7331 |
|
7332 | if (!isUndefined(from._f)) {
|
7333 | to._f = from._f;
|
7334 | }
|
7335 |
|
7336 | if (!isUndefined(from._l)) {
|
7337 | to._l = from._l;
|
7338 | }
|
7339 |
|
7340 | if (!isUndefined(from._strict)) {
|
7341 | to._strict = from._strict;
|
7342 | }
|
7343 |
|
7344 | if (!isUndefined(from._tzm)) {
|
7345 | to._tzm = from._tzm;
|
7346 | }
|
7347 |
|
7348 | if (!isUndefined(from._isUTC)) {
|
7349 | to._isUTC = from._isUTC;
|
7350 | }
|
7351 |
|
7352 | if (!isUndefined(from._offset)) {
|
7353 | to._offset = from._offset;
|
7354 | }
|
7355 |
|
7356 | if (!isUndefined(from._pf)) {
|
7357 | to._pf = getParsingFlags(from);
|
7358 | }
|
7359 |
|
7360 | if (!isUndefined(from._locale)) {
|
7361 | to._locale = from._locale;
|
7362 | }
|
7363 |
|
7364 | if (momentProperties.length > 0) {
|
7365 | for (i = 0; i < momentProperties.length; i++) {
|
7366 | prop = momentProperties[i];
|
7367 | val = from[prop];
|
7368 |
|
7369 | if (!isUndefined(val)) {
|
7370 | to[prop] = val;
|
7371 | }
|
7372 | }
|
7373 | }
|
7374 |
|
7375 | return to;
|
7376 | }
|
7377 |
|
7378 | var updateInProgress = false;
|
7379 |
|
7380 | function Moment(config) {
|
7381 | copyConfig(this, config);
|
7382 | this._d = new Date(config._d != null ? config._d.getTime() : NaN);
|
7383 |
|
7384 | if (!this.isValid()) {
|
7385 | this._d = new Date(NaN);
|
7386 | }
|
7387 |
|
7388 |
|
7389 |
|
7390 | if (updateInProgress === false) {
|
7391 | updateInProgress = true;
|
7392 | hooks.updateOffset(this);
|
7393 | updateInProgress = false;
|
7394 | }
|
7395 | }
|
7396 |
|
7397 | function isMoment(obj) {
|
7398 | return obj instanceof Moment || obj != null && obj._isAMomentObject != null;
|
7399 | }
|
7400 |
|
7401 | function absFloor(number) {
|
7402 | if (number < 0) {
|
7403 |
|
7404 | return Math.ceil(number) || 0;
|
7405 | } else {
|
7406 | return Math.floor(number);
|
7407 | }
|
7408 | }
|
7409 |
|
7410 | function toInt(argumentForCoercion) {
|
7411 | var coercedNumber = +argumentForCoercion,
|
7412 | value = 0;
|
7413 |
|
7414 | if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
7415 | value = absFloor(coercedNumber);
|
7416 | }
|
7417 |
|
7418 | return value;
|
7419 | }
|
7420 |
|
7421 |
|
7422 | function compareArrays(array1, array2, dontConvert) {
|
7423 | var len = Math.min(array1.length, array2.length),
|
7424 | lengthDiff = Math.abs(array1.length - array2.length),
|
7425 | diffs = 0,
|
7426 | i;
|
7427 |
|
7428 | for (i = 0; i < len; i++) {
|
7429 | if (dontConvert && array1[i] !== array2[i] || !dontConvert && toInt(array1[i]) !== toInt(array2[i])) {
|
7430 | diffs++;
|
7431 | }
|
7432 | }
|
7433 |
|
7434 | return diffs + lengthDiff;
|
7435 | }
|
7436 |
|
7437 | function warn(msg) {
|
7438 | if (hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
|
7439 | console.warn('Deprecation warning: ' + msg);
|
7440 | }
|
7441 | }
|
7442 |
|
7443 | function deprecate(msg, fn) {
|
7444 | var firstTime = true;
|
7445 | return extend(function () {
|
7446 | if (hooks.deprecationHandler != null) {
|
7447 | hooks.deprecationHandler(null, msg);
|
7448 | }
|
7449 |
|
7450 | if (firstTime) {
|
7451 | var args = [];
|
7452 | var arg;
|
7453 |
|
7454 | for (var i = 0; i < arguments.length; i++) {
|
7455 | arg = '';
|
7456 |
|
7457 | if (typeof arguments[i] === 'object') {
|
7458 | arg += '\n[' + i + '] ';
|
7459 |
|
7460 | for (var key in arguments[0]) {
|
7461 | arg += key + ': ' + arguments[0][key] + ', ';
|
7462 | }
|
7463 |
|
7464 | arg = arg.slice(0, -2);
|
7465 | } else {
|
7466 | arg = arguments[i];
|
7467 | }
|
7468 |
|
7469 | args.push(arg);
|
7470 | }
|
7471 |
|
7472 | warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + new Error().stack);
|
7473 | firstTime = false;
|
7474 | }
|
7475 |
|
7476 | return fn.apply(this, arguments);
|
7477 | }, fn);
|
7478 | }
|
7479 |
|
7480 | var deprecations = {};
|
7481 |
|
7482 | function deprecateSimple(name, msg) {
|
7483 | if (hooks.deprecationHandler != null) {
|
7484 | hooks.deprecationHandler(name, msg);
|
7485 | }
|
7486 |
|
7487 | if (!deprecations[name]) {
|
7488 | warn(msg);
|
7489 | deprecations[name] = true;
|
7490 | }
|
7491 | }
|
7492 |
|
7493 | hooks.suppressDeprecationWarnings = false;
|
7494 | hooks.deprecationHandler = null;
|
7495 |
|
7496 | function isFunction(input) {
|
7497 | return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
7498 | }
|
7499 |
|
7500 | function set(config) {
|
7501 | var prop, i;
|
7502 |
|
7503 | for (i in config) {
|
7504 | prop = config[i];
|
7505 |
|
7506 | if (isFunction(prop)) {
|
7507 | this[i] = prop;
|
7508 | } else {
|
7509 | this['_' + i] = prop;
|
7510 | }
|
7511 | }
|
7512 |
|
7513 | this._config = config;
|
7514 |
|
7515 |
|
7516 |
|
7517 | this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source);
|
7518 | }
|
7519 |
|
7520 | function mergeConfigs(parentConfig, childConfig) {
|
7521 | var res = extend({}, parentConfig),
|
7522 | prop;
|
7523 |
|
7524 | for (prop in childConfig) {
|
7525 | if (hasOwnProp(childConfig, prop)) {
|
7526 | if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
|
7527 | res[prop] = {};
|
7528 | extend(res[prop], parentConfig[prop]);
|
7529 | extend(res[prop], childConfig[prop]);
|
7530 | } else if (childConfig[prop] != null) {
|
7531 | res[prop] = childConfig[prop];
|
7532 | } else {
|
7533 | delete res[prop];
|
7534 | }
|
7535 | }
|
7536 | }
|
7537 |
|
7538 | for (prop in parentConfig) {
|
7539 | if (hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop])) {
|
7540 |
|
7541 | res[prop] = extend({}, res[prop]);
|
7542 | }
|
7543 | }
|
7544 |
|
7545 | return res;
|
7546 | }
|
7547 |
|
7548 | function Locale(config) {
|
7549 | if (config != null) {
|
7550 | this.set(config);
|
7551 | }
|
7552 | }
|
7553 |
|
7554 | var keys;
|
7555 |
|
7556 | if (Object.keys) {
|
7557 | keys = Object.keys;
|
7558 | } else {
|
7559 | keys = function (obj) {
|
7560 | var i,
|
7561 | res = [];
|
7562 |
|
7563 | for (i in obj) {
|
7564 | if (hasOwnProp(obj, i)) {
|
7565 | res.push(i);
|
7566 | }
|
7567 | }
|
7568 |
|
7569 | return res;
|
7570 | };
|
7571 | }
|
7572 |
|
7573 | var defaultCalendar = {
|
7574 | sameDay: '[Today at] LT',
|
7575 | nextDay: '[Tomorrow at] LT',
|
7576 | nextWeek: 'dddd [at] LT',
|
7577 | lastDay: '[Yesterday at] LT',
|
7578 | lastWeek: '[Last] dddd [at] LT',
|
7579 | sameElse: 'L'
|
7580 | };
|
7581 |
|
7582 | function calendar(key, mom, now) {
|
7583 | var output = this._calendar[key] || this._calendar['sameElse'];
|
7584 | return isFunction(output) ? output.call(mom, now) : output;
|
7585 | }
|
7586 |
|
7587 | var defaultLongDateFormat = {
|
7588 | LTS: 'h:mm:ss A',
|
7589 | LT: 'h:mm A',
|
7590 | L: 'MM/DD/YYYY',
|
7591 | LL: 'MMMM D, YYYY',
|
7592 | LLL: 'MMMM D, YYYY h:mm A',
|
7593 | LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
7594 | };
|
7595 |
|
7596 | function longDateFormat(key) {
|
7597 | var format = this._longDateFormat[key],
|
7598 | formatUpper = this._longDateFormat[key.toUpperCase()];
|
7599 |
|
7600 | if (format || !formatUpper) {
|
7601 | return format;
|
7602 | }
|
7603 |
|
7604 | this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
7605 | return val.slice(1);
|
7606 | });
|
7607 | return this._longDateFormat[key];
|
7608 | }
|
7609 |
|
7610 | var defaultInvalidDate = 'Invalid date';
|
7611 |
|
7612 | function invalidDate() {
|
7613 | return this._invalidDate;
|
7614 | }
|
7615 |
|
7616 | var defaultOrdinal = '%d';
|
7617 | var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
|
7618 |
|
7619 | function ordinal(number) {
|
7620 | return this._ordinal.replace('%d', number);
|
7621 | }
|
7622 |
|
7623 | var defaultRelativeTime = {
|
7624 | future: 'in %s',
|
7625 | past: '%s ago',
|
7626 | s: 'a few seconds',
|
7627 | ss: '%d seconds',
|
7628 | m: 'a minute',
|
7629 | mm: '%d minutes',
|
7630 | h: 'an hour',
|
7631 | hh: '%d hours',
|
7632 | d: 'a day',
|
7633 | dd: '%d days',
|
7634 | M: 'a month',
|
7635 | MM: '%d months',
|
7636 | y: 'a year',
|
7637 | yy: '%d years'
|
7638 | };
|
7639 |
|
7640 | function relativeTime(number, withoutSuffix, string, isFuture) {
|
7641 | var output = this._relativeTime[string];
|
7642 | return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number);
|
7643 | }
|
7644 |
|
7645 | function pastFuture(diff, output) {
|
7646 | var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
7647 | return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
7648 | }
|
7649 |
|
7650 | var aliases = {};
|
7651 |
|
7652 | function addUnitAlias(unit, shorthand) {
|
7653 | var lowerCase = unit.toLowerCase();
|
7654 | aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
|
7655 | }
|
7656 |
|
7657 | function normalizeUnits(units) {
|
7658 | return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
|
7659 | }
|
7660 |
|
7661 | function normalizeObjectUnits(inputObject) {
|
7662 | var normalizedInput = {},
|
7663 | normalizedProp,
|
7664 | prop;
|
7665 |
|
7666 | for (prop in inputObject) {
|
7667 | if (hasOwnProp(inputObject, prop)) {
|
7668 | normalizedProp = normalizeUnits(prop);
|
7669 |
|
7670 | if (normalizedProp) {
|
7671 | normalizedInput[normalizedProp] = inputObject[prop];
|
7672 | }
|
7673 | }
|
7674 | }
|
7675 |
|
7676 | return normalizedInput;
|
7677 | }
|
7678 |
|
7679 | var priorities = {};
|
7680 |
|
7681 | function addUnitPriority(unit, priority) {
|
7682 | priorities[unit] = priority;
|
7683 | }
|
7684 |
|
7685 | function getPrioritizedUnits(unitsObj) {
|
7686 | var units = [];
|
7687 |
|
7688 | for (var u in unitsObj) {
|
7689 | units.push({
|
7690 | unit: u,
|
7691 | priority: priorities[u]
|
7692 | });
|
7693 | }
|
7694 |
|
7695 | units.sort(function (a, b) {
|
7696 | return a.priority - b.priority;
|
7697 | });
|
7698 | return units;
|
7699 | }
|
7700 |
|
7701 | function zeroFill(number, targetLength, forceSign) {
|
7702 | var absNumber = '' + Math.abs(number),
|
7703 | zerosToFill = targetLength - absNumber.length,
|
7704 | sign = number >= 0;
|
7705 | return (sign ? forceSign ? '+' : '' : '-') + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
7706 | }
|
7707 |
|
7708 | var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
|
7709 | var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
7710 | var formatFunctions = {};
|
7711 | var formatTokenFunctions = {};
|
7712 |
|
7713 |
|
7714 |
|
7715 |
|
7716 | function addFormatToken(token, padded, ordinal, callback) {
|
7717 | var func = callback;
|
7718 |
|
7719 | if (typeof callback === 'string') {
|
7720 | func = function () {
|
7721 | return this[callback]();
|
7722 | };
|
7723 | }
|
7724 |
|
7725 | if (token) {
|
7726 | formatTokenFunctions[token] = func;
|
7727 | }
|
7728 |
|
7729 | if (padded) {
|
7730 | formatTokenFunctions[padded[0]] = function () {
|
7731 | return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
|
7732 | };
|
7733 | }
|
7734 |
|
7735 | if (ordinal) {
|
7736 | formatTokenFunctions[ordinal] = function () {
|
7737 | return this.localeData().ordinal(func.apply(this, arguments), token);
|
7738 | };
|
7739 | }
|
7740 | }
|
7741 |
|
7742 | function removeFormattingTokens(input) {
|
7743 | if (input.match(/\[[\s\S]/)) {
|
7744 | return input.replace(/^\[|\]$/g, '');
|
7745 | }
|
7746 |
|
7747 | return input.replace(/\\/g, '');
|
7748 | }
|
7749 |
|
7750 | function makeFormatFunction(format) {
|
7751 | var array = format.match(formattingTokens),
|
7752 | i,
|
7753 | length;
|
7754 |
|
7755 | for (i = 0, length = array.length; i < length; i++) {
|
7756 | if (formatTokenFunctions[array[i]]) {
|
7757 | array[i] = formatTokenFunctions[array[i]];
|
7758 | } else {
|
7759 | array[i] = removeFormattingTokens(array[i]);
|
7760 | }
|
7761 | }
|
7762 |
|
7763 | return function (mom) {
|
7764 | var output = '',
|
7765 | i;
|
7766 |
|
7767 | for (i = 0; i < length; i++) {
|
7768 | output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
|
7769 | }
|
7770 |
|
7771 | return output;
|
7772 | };
|
7773 | }
|
7774 |
|
7775 |
|
7776 | function formatMoment(m, format) {
|
7777 | if (!m.isValid()) {
|
7778 | return m.localeData().invalidDate();
|
7779 | }
|
7780 |
|
7781 | format = expandFormat(format, m.localeData());
|
7782 | formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
|
7783 | return formatFunctions[format](m);
|
7784 | }
|
7785 |
|
7786 | function expandFormat(format, locale) {
|
7787 | var i = 5;
|
7788 |
|
7789 | function replaceLongDateFormatTokens(input) {
|
7790 | return locale.longDateFormat(input) || input;
|
7791 | }
|
7792 |
|
7793 | localFormattingTokens.lastIndex = 0;
|
7794 |
|
7795 | while (i >= 0 && localFormattingTokens.test(format)) {
|
7796 | format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
7797 | localFormattingTokens.lastIndex = 0;
|
7798 | i -= 1;
|
7799 | }
|
7800 |
|
7801 | return format;
|
7802 | }
|
7803 |
|
7804 | var match1 = /\d/;
|
7805 |
|
7806 | var match2 = /\d\d/;
|
7807 |
|
7808 | var match3 = /\d{3}/;
|
7809 |
|
7810 | var match4 = /\d{4}/;
|
7811 |
|
7812 | var match6 = /[+-]?\d{6}/;
|
7813 |
|
7814 | var match1to2 = /\d\d?/;
|
7815 |
|
7816 | var match3to4 = /\d\d\d\d?/;
|
7817 |
|
7818 | var match5to6 = /\d\d\d\d\d\d?/;
|
7819 |
|
7820 | var match1to3 = /\d{1,3}/;
|
7821 |
|
7822 | var match1to4 = /\d{1,4}/;
|
7823 |
|
7824 | var match1to6 = /[+-]?\d{1,6}/;
|
7825 |
|
7826 | var matchUnsigned = /\d+/;
|
7827 |
|
7828 | var matchSigned = /[+-]?\d+/;
|
7829 |
|
7830 | var matchOffset = /Z|[+-]\d\d:?\d\d/gi;
|
7831 |
|
7832 | var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi;
|
7833 |
|
7834 | var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
7835 |
|
7836 |
|
7837 |
|
7838 | var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
|
7839 | var regexes = {};
|
7840 |
|
7841 | function addRegexToken(token, regex, strictRegex) {
|
7842 | regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
|
7843 | return isStrict && strictRegex ? strictRegex : regex;
|
7844 | };
|
7845 | }
|
7846 |
|
7847 | function getParseRegexForToken(token, config) {
|
7848 | if (!hasOwnProp(regexes, token)) {
|
7849 | return new RegExp(unescapeFormat(token));
|
7850 | }
|
7851 |
|
7852 | return regexes[token](config._strict, config._locale);
|
7853 | }
|
7854 |
|
7855 |
|
7856 | function unescapeFormat(s) {
|
7857 | return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
|
7858 | return p1 || p2 || p3 || p4;
|
7859 | }));
|
7860 | }
|
7861 |
|
7862 | function regexEscape(s) {
|
7863 | return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
7864 | }
|
7865 |
|
7866 | var tokens = {};
|
7867 |
|
7868 | function addParseToken(token, callback) {
|
7869 | var i,
|
7870 | func = callback;
|
7871 |
|
7872 | if (typeof token === 'string') {
|
7873 | token = [token];
|
7874 | }
|
7875 |
|
7876 | if (isNumber(callback)) {
|
7877 | func = function (input, array) {
|
7878 | array[callback] = toInt(input);
|
7879 | };
|
7880 | }
|
7881 |
|
7882 | for (i = 0; i < token.length; i++) {
|
7883 | tokens[token[i]] = func;
|
7884 | }
|
7885 | }
|
7886 |
|
7887 | function addWeekParseToken(token, callback) {
|
7888 | addParseToken(token, function (input, array, config, token) {
|
7889 | config._w = config._w || {};
|
7890 | callback(input, config._w, config, token);
|
7891 | });
|
7892 | }
|
7893 |
|
7894 | function addTimeToArrayFromToken(token, input, config) {
|
7895 | if (input != null && hasOwnProp(tokens, token)) {
|
7896 | tokens[token](input, config._a, config, token);
|
7897 | }
|
7898 | }
|
7899 |
|
7900 | var YEAR = 0;
|
7901 | var MONTH = 1;
|
7902 | var DATE = 2;
|
7903 | var HOUR = 3;
|
7904 | var MINUTE = 4;
|
7905 | var SECOND = 5;
|
7906 | var MILLISECOND = 6;
|
7907 | var WEEK = 7;
|
7908 | var WEEKDAY = 8;
|
7909 |
|
7910 | addFormatToken('Y', 0, 0, function () {
|
7911 | var y = this.year();
|
7912 | return y <= 9999 ? '' + y : '+' + y;
|
7913 | });
|
7914 | addFormatToken(0, ['YY', 2], 0, function () {
|
7915 | return this.year() % 100;
|
7916 | });
|
7917 | addFormatToken(0, ['YYYY', 4], 0, 'year');
|
7918 | addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
7919 | addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
7920 |
|
7921 | addUnitAlias('year', 'y');
|
7922 |
|
7923 | addUnitPriority('year', 1);
|
7924 |
|
7925 | addRegexToken('Y', matchSigned);
|
7926 | addRegexToken('YY', match1to2, match2);
|
7927 | addRegexToken('YYYY', match1to4, match4);
|
7928 | addRegexToken('YYYYY', match1to6, match6);
|
7929 | addRegexToken('YYYYYY', match1to6, match6);
|
7930 | addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
7931 | addParseToken('YYYY', function (input, array) {
|
7932 | array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
|
7933 | });
|
7934 | addParseToken('YY', function (input, array) {
|
7935 | array[YEAR] = hooks.parseTwoDigitYear(input);
|
7936 | });
|
7937 | addParseToken('Y', function (input, array) {
|
7938 | array[YEAR] = parseInt(input, 10);
|
7939 | });
|
7940 |
|
7941 | function daysInYear(year) {
|
7942 | return isLeapYear(year) ? 366 : 365;
|
7943 | }
|
7944 |
|
7945 | function isLeapYear(year) {
|
7946 | return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
7947 | }
|
7948 |
|
7949 |
|
7950 | hooks.parseTwoDigitYear = function (input) {
|
7951 | return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
7952 | };
|
7953 |
|
7954 |
|
7955 | var getSetYear = makeGetSet('FullYear', true);
|
7956 |
|
7957 | function getIsLeapYear() {
|
7958 | return isLeapYear(this.year());
|
7959 | }
|
7960 |
|
7961 | function makeGetSet(unit, keepTime) {
|
7962 | return function (value) {
|
7963 | if (value != null) {
|
7964 | set$1(this, unit, value);
|
7965 | hooks.updateOffset(this, keepTime);
|
7966 | return this;
|
7967 | } else {
|
7968 | return get(this, unit);
|
7969 | }
|
7970 | };
|
7971 | }
|
7972 |
|
7973 | function get(mom, unit) {
|
7974 | return mom.isValid() ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
|
7975 | }
|
7976 |
|
7977 | function set$1(mom, unit, value) {
|
7978 | if (mom.isValid() && !isNaN(value)) {
|
7979 | if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
|
7980 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
|
7981 | } else {
|
7982 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
7983 | }
|
7984 | }
|
7985 | }
|
7986 |
|
7987 |
|
7988 | function stringGet(units) {
|
7989 | units = normalizeUnits(units);
|
7990 |
|
7991 | if (isFunction(this[units])) {
|
7992 | return this[units]();
|
7993 | }
|
7994 |
|
7995 | return this;
|
7996 | }
|
7997 |
|
7998 | function stringSet(units, value) {
|
7999 | if (typeof units === 'object') {
|
8000 | units = normalizeObjectUnits(units);
|
8001 | var prioritized = getPrioritizedUnits(units);
|
8002 |
|
8003 | for (var i = 0; i < prioritized.length; i++) {
|
8004 | this[prioritized[i].unit](units[prioritized[i].unit]);
|
8005 | }
|
8006 | } else {
|
8007 | units = normalizeUnits(units);
|
8008 |
|
8009 | if (isFunction(this[units])) {
|
8010 | return this[units](value);
|
8011 | }
|
8012 | }
|
8013 |
|
8014 | return this;
|
8015 | }
|
8016 |
|
8017 | function mod(n, x) {
|
8018 | return (n % x + x) % x;
|
8019 | }
|
8020 |
|
8021 | var indexOf;
|
8022 |
|
8023 | if (Array.prototype.indexOf) {
|
8024 | indexOf = Array.prototype.indexOf;
|
8025 | } else {
|
8026 | indexOf = function (o) {
|
8027 |
|
8028 | var i;
|
8029 |
|
8030 | for (i = 0; i < this.length; ++i) {
|
8031 | if (this[i] === o) {
|
8032 | return i;
|
8033 | }
|
8034 | }
|
8035 |
|
8036 | return -1;
|
8037 | };
|
8038 | }
|
8039 |
|
8040 | function daysInMonth(year, month) {
|
8041 | if (isNaN(year) || isNaN(month)) {
|
8042 | return NaN;
|
8043 | }
|
8044 |
|
8045 | var modMonth = mod(month, 12);
|
8046 | year += (month - modMonth) / 12;
|
8047 | return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - modMonth % 7 % 2;
|
8048 | }
|
8049 |
|
8050 |
|
8051 | addFormatToken('M', ['MM', 2], 'Mo', function () {
|
8052 | return this.month() + 1;
|
8053 | });
|
8054 | addFormatToken('MMM', 0, 0, function (format) {
|
8055 | return this.localeData().monthsShort(this, format);
|
8056 | });
|
8057 | addFormatToken('MMMM', 0, 0, function (format) {
|
8058 | return this.localeData().months(this, format);
|
8059 | });
|
8060 |
|
8061 | addUnitAlias('month', 'M');
|
8062 |
|
8063 | addUnitPriority('month', 8);
|
8064 |
|
8065 | addRegexToken('M', match1to2);
|
8066 | addRegexToken('MM', match1to2, match2);
|
8067 | addRegexToken('MMM', function (isStrict, locale) {
|
8068 | return locale.monthsShortRegex(isStrict);
|
8069 | });
|
8070 | addRegexToken('MMMM', function (isStrict, locale) {
|
8071 | return locale.monthsRegex(isStrict);
|
8072 | });
|
8073 | addParseToken(['M', 'MM'], function (input, array) {
|
8074 | array[MONTH] = toInt(input) - 1;
|
8075 | });
|
8076 | addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
|
8077 | var month = config._locale.monthsParse(input, token, config._strict);
|
8078 |
|
8079 |
|
8080 | if (month != null) {
|
8081 | array[MONTH] = month;
|
8082 | } else {
|
8083 | getParsingFlags(config).invalidMonth = input;
|
8084 | }
|
8085 | });
|
8086 |
|
8087 | var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
|
8088 | var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
8089 |
|
8090 | function localeMonths(m, format) {
|
8091 | if (!m) {
|
8092 | return isArray(this._months) ? this._months : this._months['standalone'];
|
8093 | }
|
8094 |
|
8095 | return isArray(this._months) ? this._months[m.month()] : this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
|
8096 | }
|
8097 |
|
8098 | var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
8099 |
|
8100 | function localeMonthsShort(m, format) {
|
8101 | if (!m) {
|
8102 | return isArray(this._monthsShort) ? this._monthsShort : this._monthsShort['standalone'];
|
8103 | }
|
8104 |
|
8105 | return isArray(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
8106 | }
|
8107 |
|
8108 | function handleStrictParse(monthName, format, strict) {
|
8109 | var i,
|
8110 | ii,
|
8111 | mom,
|
8112 | llc = monthName.toLocaleLowerCase();
|
8113 |
|
8114 | if (!this._monthsParse) {
|
8115 |
|
8116 | this._monthsParse = [];
|
8117 | this._longMonthsParse = [];
|
8118 | this._shortMonthsParse = [];
|
8119 |
|
8120 | for (i = 0; i < 12; ++i) {
|
8121 | mom = createUTC([2000, i]);
|
8122 | this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
8123 | this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
8124 | }
|
8125 | }
|
8126 |
|
8127 | if (strict) {
|
8128 | if (format === 'MMM') {
|
8129 | ii = indexOf.call(this._shortMonthsParse, llc);
|
8130 | return ii !== -1 ? ii : null;
|
8131 | } else {
|
8132 | ii = indexOf.call(this._longMonthsParse, llc);
|
8133 | return ii !== -1 ? ii : null;
|
8134 | }
|
8135 | } else {
|
8136 | if (format === 'MMM') {
|
8137 | ii = indexOf.call(this._shortMonthsParse, llc);
|
8138 |
|
8139 | if (ii !== -1) {
|
8140 | return ii;
|
8141 | }
|
8142 |
|
8143 | ii = indexOf.call(this._longMonthsParse, llc);
|
8144 | return ii !== -1 ? ii : null;
|
8145 | } else {
|
8146 | ii = indexOf.call(this._longMonthsParse, llc);
|
8147 |
|
8148 | if (ii !== -1) {
|
8149 | return ii;
|
8150 | }
|
8151 |
|
8152 | ii = indexOf.call(this._shortMonthsParse, llc);
|
8153 | return ii !== -1 ? ii : null;
|
8154 | }
|
8155 | }
|
8156 | }
|
8157 |
|
8158 | function localeMonthsParse(monthName, format, strict) {
|
8159 | var i, mom, regex;
|
8160 |
|
8161 | if (this._monthsParseExact) {
|
8162 | return handleStrictParse.call(this, monthName, format, strict);
|
8163 | }
|
8164 |
|
8165 | if (!this._monthsParse) {
|
8166 | this._monthsParse = [];
|
8167 | this._longMonthsParse = [];
|
8168 | this._shortMonthsParse = [];
|
8169 | }
|
8170 |
|
8171 |
|
8172 |
|
8173 |
|
8174 | for (i = 0; i < 12; i++) {
|
8175 |
|
8176 | mom = createUTC([2000, i]);
|
8177 |
|
8178 | if (strict && !this._longMonthsParse[i]) {
|
8179 | this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
8180 | this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
8181 | }
|
8182 |
|
8183 | if (!strict && !this._monthsParse[i]) {
|
8184 | regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
8185 | this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
8186 | }
|
8187 |
|
8188 |
|
8189 | if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
|
8190 | return i;
|
8191 | } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
|
8192 | return i;
|
8193 | } else if (!strict && this._monthsParse[i].test(monthName)) {
|
8194 | return i;
|
8195 | }
|
8196 | }
|
8197 | }
|
8198 |
|
8199 |
|
8200 | function setMonth(mom, value) {
|
8201 | var dayOfMonth;
|
8202 |
|
8203 | if (!mom.isValid()) {
|
8204 |
|
8205 | return mom;
|
8206 | }
|
8207 |
|
8208 | if (typeof value === 'string') {
|
8209 | if (/^\d+$/.test(value)) {
|
8210 | value = toInt(value);
|
8211 | } else {
|
8212 | value = mom.localeData().monthsParse(value);
|
8213 |
|
8214 | if (!isNumber(value)) {
|
8215 | return mom;
|
8216 | }
|
8217 | }
|
8218 | }
|
8219 |
|
8220 | dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
|
8221 |
|
8222 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
8223 |
|
8224 | return mom;
|
8225 | }
|
8226 |
|
8227 | function getSetMonth(value) {
|
8228 | if (value != null) {
|
8229 | setMonth(this, value);
|
8230 | hooks.updateOffset(this, true);
|
8231 | return this;
|
8232 | } else {
|
8233 | return get(this, 'Month');
|
8234 | }
|
8235 | }
|
8236 |
|
8237 | function getDaysInMonth() {
|
8238 | return daysInMonth(this.year(), this.month());
|
8239 | }
|
8240 |
|
8241 | var defaultMonthsShortRegex = matchWord;
|
8242 |
|
8243 | function monthsShortRegex(isStrict) {
|
8244 | if (this._monthsParseExact) {
|
8245 | if (!hasOwnProp(this, '_monthsRegex')) {
|
8246 | computeMonthsParse.call(this);
|
8247 | }
|
8248 |
|
8249 | if (isStrict) {
|
8250 | return this._monthsShortStrictRegex;
|
8251 | } else {
|
8252 | return this._monthsShortRegex;
|
8253 | }
|
8254 | } else {
|
8255 | if (!hasOwnProp(this, '_monthsShortRegex')) {
|
8256 | this._monthsShortRegex = defaultMonthsShortRegex;
|
8257 | }
|
8258 |
|
8259 | return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex;
|
8260 | }
|
8261 | }
|
8262 |
|
8263 | var defaultMonthsRegex = matchWord;
|
8264 |
|
8265 | function monthsRegex(isStrict) {
|
8266 | if (this._monthsParseExact) {
|
8267 | if (!hasOwnProp(this, '_monthsRegex')) {
|
8268 | computeMonthsParse.call(this);
|
8269 | }
|
8270 |
|
8271 | if (isStrict) {
|
8272 | return this._monthsStrictRegex;
|
8273 | } else {
|
8274 | return this._monthsRegex;
|
8275 | }
|
8276 | } else {
|
8277 | if (!hasOwnProp(this, '_monthsRegex')) {
|
8278 | this._monthsRegex = defaultMonthsRegex;
|
8279 | }
|
8280 |
|
8281 | return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex;
|
8282 | }
|
8283 | }
|
8284 |
|
8285 | function computeMonthsParse() {
|
8286 | function cmpLenRev(a, b) {
|
8287 | return b.length - a.length;
|
8288 | }
|
8289 |
|
8290 | var shortPieces = [],
|
8291 | longPieces = [],
|
8292 | mixedPieces = [],
|
8293 | i,
|
8294 | mom;
|
8295 |
|
8296 | for (i = 0; i < 12; i++) {
|
8297 |
|
8298 | mom = createUTC([2000, i]);
|
8299 | shortPieces.push(this.monthsShort(mom, ''));
|
8300 | longPieces.push(this.months(mom, ''));
|
8301 | mixedPieces.push(this.months(mom, ''));
|
8302 | mixedPieces.push(this.monthsShort(mom, ''));
|
8303 | }
|
8304 |
|
8305 |
|
8306 |
|
8307 | shortPieces.sort(cmpLenRev);
|
8308 | longPieces.sort(cmpLenRev);
|
8309 | mixedPieces.sort(cmpLenRev);
|
8310 |
|
8311 | for (i = 0; i < 12; i++) {
|
8312 | shortPieces[i] = regexEscape(shortPieces[i]);
|
8313 | longPieces[i] = regexEscape(longPieces[i]);
|
8314 | }
|
8315 |
|
8316 | for (i = 0; i < 24; i++) {
|
8317 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
8318 | }
|
8319 |
|
8320 | this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
8321 | this._monthsShortRegex = this._monthsRegex;
|
8322 | this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
8323 | this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
8324 | }
|
8325 |
|
8326 | function createDate(y, m, d, h, M, s, ms) {
|
8327 |
|
8328 |
|
8329 | var date;
|
8330 |
|
8331 | if (y < 100 && y >= 0) {
|
8332 |
|
8333 | date = new Date(y + 400, m, d, h, M, s, ms);
|
8334 |
|
8335 | if (isFinite(date.getFullYear())) {
|
8336 | date.setFullYear(y);
|
8337 | }
|
8338 | } else {
|
8339 | date = new Date(y, m, d, h, M, s, ms);
|
8340 | }
|
8341 |
|
8342 | return date;
|
8343 | }
|
8344 |
|
8345 | function createUTCDate(y) {
|
8346 | var date;
|
8347 |
|
8348 | if (y < 100 && y >= 0) {
|
8349 | var args = Array.prototype.slice.call(arguments);
|
8350 |
|
8351 | args[0] = y + 400;
|
8352 | date = new Date(Date.UTC.apply(null, args));
|
8353 |
|
8354 | if (isFinite(date.getUTCFullYear())) {
|
8355 | date.setUTCFullYear(y);
|
8356 | }
|
8357 | } else {
|
8358 | date = new Date(Date.UTC.apply(null, arguments));
|
8359 | }
|
8360 |
|
8361 | return date;
|
8362 | }
|
8363 |
|
8364 |
|
8365 | function firstWeekOffset(year, dow, doy) {
|
8366 | var
|
8367 | fwd = 7 + dow - doy,
|
8368 |
|
8369 | fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
8370 | return -fwdlw + fwd - 1;
|
8371 | }
|
8372 |
|
8373 |
|
8374 | function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
8375 | var localWeekday = (7 + weekday - dow) % 7,
|
8376 | weekOffset = firstWeekOffset(year, dow, doy),
|
8377 | dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
8378 | resYear,
|
8379 | resDayOfYear;
|
8380 |
|
8381 | if (dayOfYear <= 0) {
|
8382 | resYear = year - 1;
|
8383 | resDayOfYear = daysInYear(resYear) + dayOfYear;
|
8384 | } else if (dayOfYear > daysInYear(year)) {
|
8385 | resYear = year + 1;
|
8386 | resDayOfYear = dayOfYear - daysInYear(year);
|
8387 | } else {
|
8388 | resYear = year;
|
8389 | resDayOfYear = dayOfYear;
|
8390 | }
|
8391 |
|
8392 | return {
|
8393 | year: resYear,
|
8394 | dayOfYear: resDayOfYear
|
8395 | };
|
8396 | }
|
8397 |
|
8398 | function weekOfYear(mom, dow, doy) {
|
8399 | var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
8400 | week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
8401 | resWeek,
|
8402 | resYear;
|
8403 |
|
8404 | if (week < 1) {
|
8405 | resYear = mom.year() - 1;
|
8406 | resWeek = week + weeksInYear(resYear, dow, doy);
|
8407 | } else if (week > weeksInYear(mom.year(), dow, doy)) {
|
8408 | resWeek = week - weeksInYear(mom.year(), dow, doy);
|
8409 | resYear = mom.year() + 1;
|
8410 | } else {
|
8411 | resYear = mom.year();
|
8412 | resWeek = week;
|
8413 | }
|
8414 |
|
8415 | return {
|
8416 | week: resWeek,
|
8417 | year: resYear
|
8418 | };
|
8419 | }
|
8420 |
|
8421 | function weeksInYear(year, dow, doy) {
|
8422 | var weekOffset = firstWeekOffset(year, dow, doy),
|
8423 | weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
8424 | return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
8425 | }
|
8426 |
|
8427 |
|
8428 | addFormatToken('w', ['ww', 2], 'wo', 'week');
|
8429 | addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
8430 |
|
8431 | addUnitAlias('week', 'w');
|
8432 | addUnitAlias('isoWeek', 'W');
|
8433 |
|
8434 | addUnitPriority('week', 5);
|
8435 | addUnitPriority('isoWeek', 5);
|
8436 |
|
8437 | addRegexToken('w', match1to2);
|
8438 | addRegexToken('ww', match1to2, match2);
|
8439 | addRegexToken('W', match1to2);
|
8440 | addRegexToken('WW', match1to2, match2);
|
8441 | addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
8442 | week[token.substr(0, 1)] = toInt(input);
|
8443 | });
|
8444 |
|
8445 |
|
8446 | function localeWeek(mom) {
|
8447 | return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
8448 | }
|
8449 |
|
8450 | var defaultLocaleWeek = {
|
8451 | dow: 0,
|
8452 |
|
8453 | doy: 6
|
8454 |
|
8455 | };
|
8456 |
|
8457 | function localeFirstDayOfWeek() {
|
8458 | return this._week.dow;
|
8459 | }
|
8460 |
|
8461 | function localeFirstDayOfYear() {
|
8462 | return this._week.doy;
|
8463 | }
|
8464 |
|
8465 |
|
8466 | function getSetWeek(input) {
|
8467 | var week = this.localeData().week(this);
|
8468 | return input == null ? week : this.add((input - week) * 7, 'd');
|
8469 | }
|
8470 |
|
8471 | function getSetISOWeek(input) {
|
8472 | var week = weekOfYear(this, 1, 4).week;
|
8473 | return input == null ? week : this.add((input - week) * 7, 'd');
|
8474 | }
|
8475 |
|
8476 |
|
8477 | addFormatToken('d', 0, 'do', 'day');
|
8478 | addFormatToken('dd', 0, 0, function (format) {
|
8479 | return this.localeData().weekdaysMin(this, format);
|
8480 | });
|
8481 | addFormatToken('ddd', 0, 0, function (format) {
|
8482 | return this.localeData().weekdaysShort(this, format);
|
8483 | });
|
8484 | addFormatToken('dddd', 0, 0, function (format) {
|
8485 | return this.localeData().weekdays(this, format);
|
8486 | });
|
8487 | addFormatToken('e', 0, 0, 'weekday');
|
8488 | addFormatToken('E', 0, 0, 'isoWeekday');
|
8489 |
|
8490 | addUnitAlias('day', 'd');
|
8491 | addUnitAlias('weekday', 'e');
|
8492 | addUnitAlias('isoWeekday', 'E');
|
8493 |
|
8494 | addUnitPriority('day', 11);
|
8495 | addUnitPriority('weekday', 11);
|
8496 | addUnitPriority('isoWeekday', 11);
|
8497 |
|
8498 | addRegexToken('d', match1to2);
|
8499 | addRegexToken('e', match1to2);
|
8500 | addRegexToken('E', match1to2);
|
8501 | addRegexToken('dd', function (isStrict, locale) {
|
8502 | return locale.weekdaysMinRegex(isStrict);
|
8503 | });
|
8504 | addRegexToken('ddd', function (isStrict, locale) {
|
8505 | return locale.weekdaysShortRegex(isStrict);
|
8506 | });
|
8507 | addRegexToken('dddd', function (isStrict, locale) {
|
8508 | return locale.weekdaysRegex(isStrict);
|
8509 | });
|
8510 | addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
8511 | var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
8512 |
|
8513 |
|
8514 | if (weekday != null) {
|
8515 | week.d = weekday;
|
8516 | } else {
|
8517 | getParsingFlags(config).invalidWeekday = input;
|
8518 | }
|
8519 | });
|
8520 | addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
8521 | week[token] = toInt(input);
|
8522 | });
|
8523 |
|
8524 | function parseWeekday(input, locale) {
|
8525 | if (typeof input !== 'string') {
|
8526 | return input;
|
8527 | }
|
8528 |
|
8529 | if (!isNaN(input)) {
|
8530 | return parseInt(input, 10);
|
8531 | }
|
8532 |
|
8533 | input = locale.weekdaysParse(input);
|
8534 |
|
8535 | if (typeof input === 'number') {
|
8536 | return input;
|
8537 | }
|
8538 |
|
8539 | return null;
|
8540 | }
|
8541 |
|
8542 | function parseIsoWeekday(input, locale) {
|
8543 | if (typeof input === 'string') {
|
8544 | return locale.weekdaysParse(input) % 7 || 7;
|
8545 | }
|
8546 |
|
8547 | return isNaN(input) ? null : input;
|
8548 | }
|
8549 |
|
8550 |
|
8551 | function shiftWeekdays(ws, n) {
|
8552 | return ws.slice(n, 7).concat(ws.slice(0, n));
|
8553 | }
|
8554 |
|
8555 | var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
8556 |
|
8557 | function localeWeekdays(m, format) {
|
8558 | var weekdays = isArray(this._weekdays) ? this._weekdays : this._weekdays[m && m !== true && this._weekdays.isFormat.test(format) ? 'format' : 'standalone'];
|
8559 | return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays;
|
8560 | }
|
8561 |
|
8562 | var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
8563 |
|
8564 | function localeWeekdaysShort(m) {
|
8565 | return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
8566 | }
|
8567 |
|
8568 | var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
8569 |
|
8570 | function localeWeekdaysMin(m) {
|
8571 | return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
8572 | }
|
8573 |
|
8574 | function handleStrictParse$1(weekdayName, format, strict) {
|
8575 | var i,
|
8576 | ii,
|
8577 | mom,
|
8578 | llc = weekdayName.toLocaleLowerCase();
|
8579 |
|
8580 | if (!this._weekdaysParse) {
|
8581 | this._weekdaysParse = [];
|
8582 | this._shortWeekdaysParse = [];
|
8583 | this._minWeekdaysParse = [];
|
8584 |
|
8585 | for (i = 0; i < 7; ++i) {
|
8586 | mom = createUTC([2000, 1]).day(i);
|
8587 | this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
8588 | this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
8589 | this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
8590 | }
|
8591 | }
|
8592 |
|
8593 | if (strict) {
|
8594 | if (format === 'dddd') {
|
8595 | ii = indexOf.call(this._weekdaysParse, llc);
|
8596 | return ii !== -1 ? ii : null;
|
8597 | } else if (format === 'ddd') {
|
8598 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
8599 | return ii !== -1 ? ii : null;
|
8600 | } else {
|
8601 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
8602 | return ii !== -1 ? ii : null;
|
8603 | }
|
8604 | } else {
|
8605 | if (format === 'dddd') {
|
8606 | ii = indexOf.call(this._weekdaysParse, llc);
|
8607 |
|
8608 | if (ii !== -1) {
|
8609 | return ii;
|
8610 | }
|
8611 |
|
8612 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
8613 |
|
8614 | if (ii !== -1) {
|
8615 | return ii;
|
8616 | }
|
8617 |
|
8618 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
8619 | return ii !== -1 ? ii : null;
|
8620 | } else if (format === 'ddd') {
|
8621 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
8622 |
|
8623 | if (ii !== -1) {
|
8624 | return ii;
|
8625 | }
|
8626 |
|
8627 | ii = indexOf.call(this._weekdaysParse, llc);
|
8628 |
|
8629 | if (ii !== -1) {
|
8630 | return ii;
|
8631 | }
|
8632 |
|
8633 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
8634 | return ii !== -1 ? ii : null;
|
8635 | } else {
|
8636 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
8637 |
|
8638 | if (ii !== -1) {
|
8639 | return ii;
|
8640 | }
|
8641 |
|
8642 | ii = indexOf.call(this._weekdaysParse, llc);
|
8643 |
|
8644 | if (ii !== -1) {
|
8645 | return ii;
|
8646 | }
|
8647 |
|
8648 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
8649 | return ii !== -1 ? ii : null;
|
8650 | }
|
8651 | }
|
8652 | }
|
8653 |
|
8654 | function localeWeekdaysParse(weekdayName, format, strict) {
|
8655 | var i, mom, regex;
|
8656 |
|
8657 | if (this._weekdaysParseExact) {
|
8658 | return handleStrictParse$1.call(this, weekdayName, format, strict);
|
8659 | }
|
8660 |
|
8661 | if (!this._weekdaysParse) {
|
8662 | this._weekdaysParse = [];
|
8663 | this._minWeekdaysParse = [];
|
8664 | this._shortWeekdaysParse = [];
|
8665 | this._fullWeekdaysParse = [];
|
8666 | }
|
8667 |
|
8668 | for (i = 0; i < 7; i++) {
|
8669 |
|
8670 | mom = createUTC([2000, 1]).day(i);
|
8671 |
|
8672 | if (strict && !this._fullWeekdaysParse[i]) {
|
8673 | this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
|
8674 | this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
|
8675 | this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
|
8676 | }
|
8677 |
|
8678 | if (!this._weekdaysParse[i]) {
|
8679 | regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
8680 | this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
8681 | }
|
8682 |
|
8683 |
|
8684 | if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
8685 | return i;
|
8686 | } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
8687 | return i;
|
8688 | } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
8689 | return i;
|
8690 | } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
8691 | return i;
|
8692 | }
|
8693 | }
|
8694 | }
|
8695 |
|
8696 |
|
8697 | function getSetDayOfWeek(input) {
|
8698 | if (!this.isValid()) {
|
8699 | return input != null ? this : NaN;
|
8700 | }
|
8701 |
|
8702 | var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
8703 |
|
8704 | if (input != null) {
|
8705 | input = parseWeekday(input, this.localeData());
|
8706 | return this.add(input - day, 'd');
|
8707 | } else {
|
8708 | return day;
|
8709 | }
|
8710 | }
|
8711 |
|
8712 | function getSetLocaleDayOfWeek(input) {
|
8713 | if (!this.isValid()) {
|
8714 | return input != null ? this : NaN;
|
8715 | }
|
8716 |
|
8717 | var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
8718 | return input == null ? weekday : this.add(input - weekday, 'd');
|
8719 | }
|
8720 |
|
8721 | function getSetISODayOfWeek(input) {
|
8722 | if (!this.isValid()) {
|
8723 | return input != null ? this : NaN;
|
8724 | }
|
8725 |
|
8726 |
|
8727 |
|
8728 |
|
8729 | if (input != null) {
|
8730 | var weekday = parseIsoWeekday(input, this.localeData());
|
8731 | return this.day(this.day() % 7 ? weekday : weekday - 7);
|
8732 | } else {
|
8733 | return this.day() || 7;
|
8734 | }
|
8735 | }
|
8736 |
|
8737 | var defaultWeekdaysRegex = matchWord;
|
8738 |
|
8739 | function weekdaysRegex(isStrict) {
|
8740 | if (this._weekdaysParseExact) {
|
8741 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
8742 | computeWeekdaysParse.call(this);
|
8743 | }
|
8744 |
|
8745 | if (isStrict) {
|
8746 | return this._weekdaysStrictRegex;
|
8747 | } else {
|
8748 | return this._weekdaysRegex;
|
8749 | }
|
8750 | } else {
|
8751 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
8752 | this._weekdaysRegex = defaultWeekdaysRegex;
|
8753 | }
|
8754 |
|
8755 | return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex;
|
8756 | }
|
8757 | }
|
8758 |
|
8759 | var defaultWeekdaysShortRegex = matchWord;
|
8760 |
|
8761 | function weekdaysShortRegex(isStrict) {
|
8762 | if (this._weekdaysParseExact) {
|
8763 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
8764 | computeWeekdaysParse.call(this);
|
8765 | }
|
8766 |
|
8767 | if (isStrict) {
|
8768 | return this._weekdaysShortStrictRegex;
|
8769 | } else {
|
8770 | return this._weekdaysShortRegex;
|
8771 | }
|
8772 | } else {
|
8773 | if (!hasOwnProp(this, '_weekdaysShortRegex')) {
|
8774 | this._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
8775 | }
|
8776 |
|
8777 | return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
8778 | }
|
8779 | }
|
8780 |
|
8781 | var defaultWeekdaysMinRegex = matchWord;
|
8782 |
|
8783 | function weekdaysMinRegex(isStrict) {
|
8784 | if (this._weekdaysParseExact) {
|
8785 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
8786 | computeWeekdaysParse.call(this);
|
8787 | }
|
8788 |
|
8789 | if (isStrict) {
|
8790 | return this._weekdaysMinStrictRegex;
|
8791 | } else {
|
8792 | return this._weekdaysMinRegex;
|
8793 | }
|
8794 | } else {
|
8795 | if (!hasOwnProp(this, '_weekdaysMinRegex')) {
|
8796 | this._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
8797 | }
|
8798 |
|
8799 | return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
|
8800 | }
|
8801 | }
|
8802 |
|
8803 | function computeWeekdaysParse() {
|
8804 | function cmpLenRev(a, b) {
|
8805 | return b.length - a.length;
|
8806 | }
|
8807 |
|
8808 | var minPieces = [],
|
8809 | shortPieces = [],
|
8810 | longPieces = [],
|
8811 | mixedPieces = [],
|
8812 | i,
|
8813 | mom,
|
8814 | minp,
|
8815 | shortp,
|
8816 | longp;
|
8817 |
|
8818 | for (i = 0; i < 7; i++) {
|
8819 |
|
8820 | mom = createUTC([2000, 1]).day(i);
|
8821 | minp = this.weekdaysMin(mom, '');
|
8822 | shortp = this.weekdaysShort(mom, '');
|
8823 | longp = this.weekdays(mom, '');
|
8824 | minPieces.push(minp);
|
8825 | shortPieces.push(shortp);
|
8826 | longPieces.push(longp);
|
8827 | mixedPieces.push(minp);
|
8828 | mixedPieces.push(shortp);
|
8829 | mixedPieces.push(longp);
|
8830 | }
|
8831 |
|
8832 |
|
8833 |
|
8834 | minPieces.sort(cmpLenRev);
|
8835 | shortPieces.sort(cmpLenRev);
|
8836 | longPieces.sort(cmpLenRev);
|
8837 | mixedPieces.sort(cmpLenRev);
|
8838 |
|
8839 | for (i = 0; i < 7; i++) {
|
8840 | shortPieces[i] = regexEscape(shortPieces[i]);
|
8841 | longPieces[i] = regexEscape(longPieces[i]);
|
8842 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
8843 | }
|
8844 |
|
8845 | this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
8846 | this._weekdaysShortRegex = this._weekdaysRegex;
|
8847 | this._weekdaysMinRegex = this._weekdaysRegex;
|
8848 | this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
8849 | this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
8850 | this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
|
8851 | }
|
8852 |
|
8853 |
|
8854 | function hFormat() {
|
8855 | return this.hours() % 12 || 12;
|
8856 | }
|
8857 |
|
8858 | function kFormat() {
|
8859 | return this.hours() || 24;
|
8860 | }
|
8861 |
|
8862 | addFormatToken('H', ['HH', 2], 0, 'hour');
|
8863 | addFormatToken('h', ['hh', 2], 0, hFormat);
|
8864 | addFormatToken('k', ['kk', 2], 0, kFormat);
|
8865 | addFormatToken('hmm', 0, 0, function () {
|
8866 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
8867 | });
|
8868 | addFormatToken('hmmss', 0, 0, function () {
|
8869 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
8870 | });
|
8871 | addFormatToken('Hmm', 0, 0, function () {
|
8872 | return '' + this.hours() + zeroFill(this.minutes(), 2);
|
8873 | });
|
8874 | addFormatToken('Hmmss', 0, 0, function () {
|
8875 | return '' + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
8876 | });
|
8877 |
|
8878 | function meridiem(token, lowercase) {
|
8879 | addFormatToken(token, 0, 0, function () {
|
8880 | return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
8881 | });
|
8882 | }
|
8883 |
|
8884 | meridiem('a', true);
|
8885 | meridiem('A', false);
|
8886 |
|
8887 | addUnitAlias('hour', 'h');
|
8888 |
|
8889 | addUnitPriority('hour', 13);
|
8890 |
|
8891 | function matchMeridiem(isStrict, locale) {
|
8892 | return locale._meridiemParse;
|
8893 | }
|
8894 |
|
8895 | addRegexToken('a', matchMeridiem);
|
8896 | addRegexToken('A', matchMeridiem);
|
8897 | addRegexToken('H', match1to2);
|
8898 | addRegexToken('h', match1to2);
|
8899 | addRegexToken('k', match1to2);
|
8900 | addRegexToken('HH', match1to2, match2);
|
8901 | addRegexToken('hh', match1to2, match2);
|
8902 | addRegexToken('kk', match1to2, match2);
|
8903 | addRegexToken('hmm', match3to4);
|
8904 | addRegexToken('hmmss', match5to6);
|
8905 | addRegexToken('Hmm', match3to4);
|
8906 | addRegexToken('Hmmss', match5to6);
|
8907 | addParseToken(['H', 'HH'], HOUR);
|
8908 | addParseToken(['k', 'kk'], function (input, array, config) {
|
8909 | var kInput = toInt(input);
|
8910 | array[HOUR] = kInput === 24 ? 0 : kInput;
|
8911 | });
|
8912 | addParseToken(['a', 'A'], function (input, array, config) {
|
8913 | config._isPm = config._locale.isPM(input);
|
8914 | config._meridiem = input;
|
8915 | });
|
8916 | addParseToken(['h', 'hh'], function (input, array, config) {
|
8917 | array[HOUR] = toInt(input);
|
8918 | getParsingFlags(config).bigHour = true;
|
8919 | });
|
8920 | addParseToken('hmm', function (input, array, config) {
|
8921 | var pos = input.length - 2;
|
8922 | array[HOUR] = toInt(input.substr(0, pos));
|
8923 | array[MINUTE] = toInt(input.substr(pos));
|
8924 | getParsingFlags(config).bigHour = true;
|
8925 | });
|
8926 | addParseToken('hmmss', function (input, array, config) {
|
8927 | var pos1 = input.length - 4;
|
8928 | var pos2 = input.length - 2;
|
8929 | array[HOUR] = toInt(input.substr(0, pos1));
|
8930 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
8931 | array[SECOND] = toInt(input.substr(pos2));
|
8932 | getParsingFlags(config).bigHour = true;
|
8933 | });
|
8934 | addParseToken('Hmm', function (input, array, config) {
|
8935 | var pos = input.length - 2;
|
8936 | array[HOUR] = toInt(input.substr(0, pos));
|
8937 | array[MINUTE] = toInt(input.substr(pos));
|
8938 | });
|
8939 | addParseToken('Hmmss', function (input, array, config) {
|
8940 | var pos1 = input.length - 4;
|
8941 | var pos2 = input.length - 2;
|
8942 | array[HOUR] = toInt(input.substr(0, pos1));
|
8943 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
8944 | array[SECOND] = toInt(input.substr(pos2));
|
8945 | });
|
8946 |
|
8947 | function localeIsPM(input) {
|
8948 |
|
8949 |
|
8950 | return (input + '').toLowerCase().charAt(0) === 'p';
|
8951 | }
|
8952 |
|
8953 | var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
8954 |
|
8955 | function localeMeridiem(hours, minutes, isLower) {
|
8956 | if (hours > 11) {
|
8957 | return isLower ? 'pm' : 'PM';
|
8958 | } else {
|
8959 | return isLower ? 'am' : 'AM';
|
8960 | }
|
8961 | }
|
8962 |
|
8963 |
|
8964 |
|
8965 |
|
8966 |
|
8967 |
|
8968 | var getSetHour = makeGetSet('Hours', true);
|
8969 | var baseConfig = {
|
8970 | calendar: defaultCalendar,
|
8971 | longDateFormat: defaultLongDateFormat,
|
8972 | invalidDate: defaultInvalidDate,
|
8973 | ordinal: defaultOrdinal,
|
8974 | dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
|
8975 | relativeTime: defaultRelativeTime,
|
8976 | months: defaultLocaleMonths,
|
8977 | monthsShort: defaultLocaleMonthsShort,
|
8978 | week: defaultLocaleWeek,
|
8979 | weekdays: defaultLocaleWeekdays,
|
8980 | weekdaysMin: defaultLocaleWeekdaysMin,
|
8981 | weekdaysShort: defaultLocaleWeekdaysShort,
|
8982 | meridiemParse: defaultLocaleMeridiemParse
|
8983 | };
|
8984 |
|
8985 | var locales = {};
|
8986 | var localeFamilies = {};
|
8987 | var globalLocale;
|
8988 |
|
8989 | function normalizeLocale(key) {
|
8990 | return key ? key.toLowerCase().replace('_', '-') : key;
|
8991 | }
|
8992 |
|
8993 |
|
8994 |
|
8995 |
|
8996 | function chooseLocale(names) {
|
8997 | var i = 0,
|
8998 | j,
|
8999 | next,
|
9000 | locale,
|
9001 | split;
|
9002 |
|
9003 | while (i < names.length) {
|
9004 | split = normalizeLocale(names[i]).split('-');
|
9005 | j = split.length;
|
9006 | next = normalizeLocale(names[i + 1]);
|
9007 | next = next ? next.split('-') : null;
|
9008 |
|
9009 | while (j > 0) {
|
9010 | locale = loadLocale(split.slice(0, j).join('-'));
|
9011 |
|
9012 | if (locale) {
|
9013 | return locale;
|
9014 | }
|
9015 |
|
9016 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
9017 |
|
9018 | break;
|
9019 | }
|
9020 |
|
9021 | j--;
|
9022 | }
|
9023 |
|
9024 | i++;
|
9025 | }
|
9026 |
|
9027 | return globalLocale;
|
9028 | }
|
9029 |
|
9030 | function loadLocale(name) {
|
9031 | var oldLocale = null;
|
9032 |
|
9033 | if (!locales[name] && 'object' !== 'undefined' && module && module.exports) {
|
9034 | try {
|
9035 | oldLocale = globalLocale._abbr;
|
9036 | var aliasedRequire = commonjsRequire$2;
|
9037 | aliasedRequire('./locale/' + name);
|
9038 | getSetGlobalLocale(oldLocale);
|
9039 | } catch (e) {}
|
9040 | }
|
9041 |
|
9042 | return locales[name];
|
9043 | }
|
9044 |
|
9045 |
|
9046 |
|
9047 |
|
9048 | function getSetGlobalLocale(key, values) {
|
9049 | var data;
|
9050 |
|
9051 | if (key) {
|
9052 | if (isUndefined(values)) {
|
9053 | data = getLocale(key);
|
9054 | } else {
|
9055 | data = defineLocale(key, values);
|
9056 | }
|
9057 |
|
9058 | if (data) {
|
9059 |
|
9060 | globalLocale = data;
|
9061 | } else {
|
9062 | if (typeof console !== 'undefined' && console.warn) {
|
9063 |
|
9064 | console.warn('Locale ' + key + ' not found. Did you forget to load it?');
|
9065 | }
|
9066 | }
|
9067 | }
|
9068 |
|
9069 | return globalLocale._abbr;
|
9070 | }
|
9071 |
|
9072 | function defineLocale(name, config) {
|
9073 | if (config !== null) {
|
9074 | var locale,
|
9075 | parentConfig = baseConfig;
|
9076 | config.abbr = name;
|
9077 |
|
9078 | if (locales[name] != null) {
|
9079 | deprecateSimple('defineLocaleOverride', 'use moment.updateLocale(localeName, config) to change ' + 'an existing locale. moment.defineLocale(localeName, ' + 'config) should only be used for creating a new locale ' + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
|
9080 | parentConfig = locales[name]._config;
|
9081 | } else if (config.parentLocale != null) {
|
9082 | if (locales[config.parentLocale] != null) {
|
9083 | parentConfig = locales[config.parentLocale]._config;
|
9084 | } else {
|
9085 | locale = loadLocale(config.parentLocale);
|
9086 |
|
9087 | if (locale != null) {
|
9088 | parentConfig = locale._config;
|
9089 | } else {
|
9090 | if (!localeFamilies[config.parentLocale]) {
|
9091 | localeFamilies[config.parentLocale] = [];
|
9092 | }
|
9093 |
|
9094 | localeFamilies[config.parentLocale].push({
|
9095 | name: name,
|
9096 | config: config
|
9097 | });
|
9098 | return null;
|
9099 | }
|
9100 | }
|
9101 | }
|
9102 |
|
9103 | locales[name] = new Locale(mergeConfigs(parentConfig, config));
|
9104 |
|
9105 | if (localeFamilies[name]) {
|
9106 | localeFamilies[name].forEach(function (x) {
|
9107 | defineLocale(x.name, x.config);
|
9108 | });
|
9109 | }
|
9110 |
|
9111 |
|
9112 |
|
9113 |
|
9114 | getSetGlobalLocale(name);
|
9115 | return locales[name];
|
9116 | } else {
|
9117 |
|
9118 | delete locales[name];
|
9119 | return null;
|
9120 | }
|
9121 | }
|
9122 |
|
9123 | function updateLocale(name, config) {
|
9124 | if (config != null) {
|
9125 | var locale,
|
9126 | tmpLocale,
|
9127 | parentConfig = baseConfig;
|
9128 |
|
9129 | tmpLocale = loadLocale(name);
|
9130 |
|
9131 | if (tmpLocale != null) {
|
9132 | parentConfig = tmpLocale._config;
|
9133 | }
|
9134 |
|
9135 | config = mergeConfigs(parentConfig, config);
|
9136 | locale = new Locale(config);
|
9137 | locale.parentLocale = locales[name];
|
9138 | locales[name] = locale;
|
9139 |
|
9140 | getSetGlobalLocale(name);
|
9141 | } else {
|
9142 |
|
9143 | if (locales[name] != null) {
|
9144 | if (locales[name].parentLocale != null) {
|
9145 | locales[name] = locales[name].parentLocale;
|
9146 | } else if (locales[name] != null) {
|
9147 | delete locales[name];
|
9148 | }
|
9149 | }
|
9150 | }
|
9151 |
|
9152 | return locales[name];
|
9153 | }
|
9154 |
|
9155 |
|
9156 | function getLocale(key) {
|
9157 | var locale;
|
9158 |
|
9159 | if (key && key._locale && key._locale._abbr) {
|
9160 | key = key._locale._abbr;
|
9161 | }
|
9162 |
|
9163 | if (!key) {
|
9164 | return globalLocale;
|
9165 | }
|
9166 |
|
9167 | if (!isArray(key)) {
|
9168 |
|
9169 | locale = loadLocale(key);
|
9170 |
|
9171 | if (locale) {
|
9172 | return locale;
|
9173 | }
|
9174 |
|
9175 | key = [key];
|
9176 | }
|
9177 |
|
9178 | return chooseLocale(key);
|
9179 | }
|
9180 |
|
9181 | function listLocales() {
|
9182 | return keys(locales);
|
9183 | }
|
9184 |
|
9185 | function checkOverflow(m) {
|
9186 | var overflow;
|
9187 | var a = m._a;
|
9188 |
|
9189 | if (a && getParsingFlags(m).overflow === -2) {
|
9190 | overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1;
|
9191 |
|
9192 | if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
9193 | overflow = DATE;
|
9194 | }
|
9195 |
|
9196 | if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
|
9197 | overflow = WEEK;
|
9198 | }
|
9199 |
|
9200 | if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
|
9201 | overflow = WEEKDAY;
|
9202 | }
|
9203 |
|
9204 | getParsingFlags(m).overflow = overflow;
|
9205 | }
|
9206 |
|
9207 | return m;
|
9208 | }
|
9209 |
|
9210 |
|
9211 | function defaults(a, b, c) {
|
9212 | if (a != null) {
|
9213 | return a;
|
9214 | }
|
9215 |
|
9216 | if (b != null) {
|
9217 | return b;
|
9218 | }
|
9219 |
|
9220 | return c;
|
9221 | }
|
9222 |
|
9223 | function currentDateArray(config) {
|
9224 |
|
9225 | var nowValue = new Date(hooks.now());
|
9226 |
|
9227 | if (config._useUTC) {
|
9228 | return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
|
9229 | }
|
9230 |
|
9231 | return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
|
9232 | }
|
9233 |
|
9234 |
|
9235 |
|
9236 |
|
9237 |
|
9238 | function configFromArray(config) {
|
9239 | var i,
|
9240 | date,
|
9241 | input = [],
|
9242 | currentDate,
|
9243 | expectedWeekday,
|
9244 | yearToUse;
|
9245 |
|
9246 | if (config._d) {
|
9247 | return;
|
9248 | }
|
9249 |
|
9250 | currentDate = currentDateArray(config);
|
9251 |
|
9252 | if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
9253 | dayOfYearFromWeekInfo(config);
|
9254 | }
|
9255 |
|
9256 |
|
9257 | if (config._dayOfYear != null) {
|
9258 | yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
9259 |
|
9260 | if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
|
9261 | getParsingFlags(config)._overflowDayOfYear = true;
|
9262 | }
|
9263 |
|
9264 | date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
9265 | config._a[MONTH] = date.getUTCMonth();
|
9266 | config._a[DATE] = date.getUTCDate();
|
9267 | }
|
9268 |
|
9269 |
|
9270 |
|
9271 |
|
9272 |
|
9273 |
|
9274 | for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
9275 | config._a[i] = input[i] = currentDate[i];
|
9276 | }
|
9277 |
|
9278 |
|
9279 | for (; i < 7; i++) {
|
9280 | config._a[i] = input[i] = config._a[i] == null ? i === 2 ? 1 : 0 : config._a[i];
|
9281 | }
|
9282 |
|
9283 |
|
9284 | if (config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0) {
|
9285 | config._nextDay = true;
|
9286 | config._a[HOUR] = 0;
|
9287 | }
|
9288 |
|
9289 | config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
|
9290 | expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
|
9291 |
|
9292 |
|
9293 | if (config._tzm != null) {
|
9294 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
9295 | }
|
9296 |
|
9297 | if (config._nextDay) {
|
9298 | config._a[HOUR] = 24;
|
9299 | }
|
9300 |
|
9301 |
|
9302 | if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
|
9303 | getParsingFlags(config).weekdayMismatch = true;
|
9304 | }
|
9305 | }
|
9306 |
|
9307 | function dayOfYearFromWeekInfo(config) {
|
9308 | var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
|
9309 | w = config._w;
|
9310 |
|
9311 | if (w.GG != null || w.W != null || w.E != null) {
|
9312 | dow = 1;
|
9313 | doy = 4;
|
9314 |
|
9315 |
|
9316 |
|
9317 |
|
9318 | weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
|
9319 | week = defaults(w.W, 1);
|
9320 | weekday = defaults(w.E, 1);
|
9321 |
|
9322 | if (weekday < 1 || weekday > 7) {
|
9323 | weekdayOverflow = true;
|
9324 | }
|
9325 | } else {
|
9326 | dow = config._locale._week.dow;
|
9327 | doy = config._locale._week.doy;
|
9328 | var curWeek = weekOfYear(createLocal(), dow, doy);
|
9329 | weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
|
9330 |
|
9331 | week = defaults(w.w, curWeek.week);
|
9332 |
|
9333 | if (w.d != null) {
|
9334 |
|
9335 | weekday = w.d;
|
9336 |
|
9337 | if (weekday < 0 || weekday > 6) {
|
9338 | weekdayOverflow = true;
|
9339 | }
|
9340 | } else if (w.e != null) {
|
9341 |
|
9342 | weekday = w.e + dow;
|
9343 |
|
9344 | if (w.e < 0 || w.e > 6) {
|
9345 | weekdayOverflow = true;
|
9346 | }
|
9347 | } else {
|
9348 |
|
9349 | weekday = dow;
|
9350 | }
|
9351 | }
|
9352 |
|
9353 | if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
|
9354 | getParsingFlags(config)._overflowWeeks = true;
|
9355 | } else if (weekdayOverflow != null) {
|
9356 | getParsingFlags(config)._overflowWeekday = true;
|
9357 | } else {
|
9358 | temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
|
9359 | config._a[YEAR] = temp.year;
|
9360 | config._dayOfYear = temp.dayOfYear;
|
9361 | }
|
9362 | }
|
9363 |
|
9364 |
|
9365 |
|
9366 | var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
|
9367 | var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
|
9368 | var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
|
9369 | var isoDates = [['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], ['GGGG-[W]WW', /\d{4}-W\d\d/, false], ['YYYY-DDD', /\d{4}-\d{3}/], ['YYYY-MM', /\d{4}-\d\d/, false], ['YYYYYYMMDD', /[+-]\d{10}/], ['YYYYMMDD', /\d{8}/],
|
9370 | ['GGGG[W]WWE', /\d{4}W\d{3}/], ['GGGG[W]WW', /\d{4}W\d{2}/, false], ['YYYYDDD', /\d{7}/]];
|
9371 |
|
9372 | var isoTimes = [['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], ['HH:mm:ss', /\d\d:\d\d:\d\d/], ['HH:mm', /\d\d:\d\d/], ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], ['HHmmss', /\d\d\d\d\d\d/], ['HHmm', /\d\d\d\d/], ['HH', /\d\d/]];
|
9373 | var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
|
9374 |
|
9375 | function configFromISO(config) {
|
9376 | var i,
|
9377 | l,
|
9378 | string = config._i,
|
9379 | match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
|
9380 | allowTime,
|
9381 | dateFormat,
|
9382 | timeFormat,
|
9383 | tzFormat;
|
9384 |
|
9385 | if (match) {
|
9386 | getParsingFlags(config).iso = true;
|
9387 |
|
9388 | for (i = 0, l = isoDates.length; i < l; i++) {
|
9389 | if (isoDates[i][1].exec(match[1])) {
|
9390 | dateFormat = isoDates[i][0];
|
9391 | allowTime = isoDates[i][2] !== false;
|
9392 | break;
|
9393 | }
|
9394 | }
|
9395 |
|
9396 | if (dateFormat == null) {
|
9397 | config._isValid = false;
|
9398 | return;
|
9399 | }
|
9400 |
|
9401 | if (match[3]) {
|
9402 | for (i = 0, l = isoTimes.length; i < l; i++) {
|
9403 | if (isoTimes[i][1].exec(match[3])) {
|
9404 |
|
9405 | timeFormat = (match[2] || ' ') + isoTimes[i][0];
|
9406 | break;
|
9407 | }
|
9408 | }
|
9409 |
|
9410 | if (timeFormat == null) {
|
9411 | config._isValid = false;
|
9412 | return;
|
9413 | }
|
9414 | }
|
9415 |
|
9416 | if (!allowTime && timeFormat != null) {
|
9417 | config._isValid = false;
|
9418 | return;
|
9419 | }
|
9420 |
|
9421 | if (match[4]) {
|
9422 | if (tzRegex.exec(match[4])) {
|
9423 | tzFormat = 'Z';
|
9424 | } else {
|
9425 | config._isValid = false;
|
9426 | return;
|
9427 | }
|
9428 | }
|
9429 |
|
9430 | config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
|
9431 | configFromStringAndFormat(config);
|
9432 | } else {
|
9433 | config._isValid = false;
|
9434 | }
|
9435 | }
|
9436 |
|
9437 |
|
9438 | var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
|
9439 |
|
9440 | function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
9441 | var result = [untruncateYear(yearStr), defaultLocaleMonthsShort.indexOf(monthStr), parseInt(dayStr, 10), parseInt(hourStr, 10), parseInt(minuteStr, 10)];
|
9442 |
|
9443 | if (secondStr) {
|
9444 | result.push(parseInt(secondStr, 10));
|
9445 | }
|
9446 |
|
9447 | return result;
|
9448 | }
|
9449 |
|
9450 | function untruncateYear(yearStr) {
|
9451 | var year = parseInt(yearStr, 10);
|
9452 |
|
9453 | if (year <= 49) {
|
9454 | return 2000 + year;
|
9455 | } else if (year <= 999) {
|
9456 | return 1900 + year;
|
9457 | }
|
9458 |
|
9459 | return year;
|
9460 | }
|
9461 |
|
9462 | function preprocessRFC2822(s) {
|
9463 |
|
9464 | return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
9465 | }
|
9466 |
|
9467 | function checkWeekday(weekdayStr, parsedInput, config) {
|
9468 | if (weekdayStr) {
|
9469 |
|
9470 | var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
|
9471 | weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
|
9472 |
|
9473 | if (weekdayProvided !== weekdayActual) {
|
9474 | getParsingFlags(config).weekdayMismatch = true;
|
9475 | config._isValid = false;
|
9476 | return false;
|
9477 | }
|
9478 | }
|
9479 |
|
9480 | return true;
|
9481 | }
|
9482 |
|
9483 | var obsOffsets = {
|
9484 | UT: 0,
|
9485 | GMT: 0,
|
9486 | EDT: -4 * 60,
|
9487 | EST: -5 * 60,
|
9488 | CDT: -5 * 60,
|
9489 | CST: -6 * 60,
|
9490 | MDT: -6 * 60,
|
9491 | MST: -7 * 60,
|
9492 | PDT: -7 * 60,
|
9493 | PST: -8 * 60
|
9494 | };
|
9495 |
|
9496 | function calculateOffset(obsOffset, militaryOffset, numOffset) {
|
9497 | if (obsOffset) {
|
9498 | return obsOffsets[obsOffset];
|
9499 | } else if (militaryOffset) {
|
9500 |
|
9501 | return 0;
|
9502 | } else {
|
9503 | var hm = parseInt(numOffset, 10);
|
9504 | var m = hm % 100,
|
9505 | h = (hm - m) / 100;
|
9506 | return h * 60 + m;
|
9507 | }
|
9508 | }
|
9509 |
|
9510 |
|
9511 | function configFromRFC2822(config) {
|
9512 | var match = rfc2822.exec(preprocessRFC2822(config._i));
|
9513 |
|
9514 | if (match) {
|
9515 | var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
|
9516 |
|
9517 | if (!checkWeekday(match[1], parsedArray, config)) {
|
9518 | return;
|
9519 | }
|
9520 |
|
9521 | config._a = parsedArray;
|
9522 | config._tzm = calculateOffset(match[8], match[9], match[10]);
|
9523 | config._d = createUTCDate.apply(null, config._a);
|
9524 |
|
9525 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
9526 |
|
9527 | getParsingFlags(config).rfc2822 = true;
|
9528 | } else {
|
9529 | config._isValid = false;
|
9530 | }
|
9531 | }
|
9532 |
|
9533 |
|
9534 | function configFromString(config) {
|
9535 | var matched = aspNetJsonRegex.exec(config._i);
|
9536 |
|
9537 | if (matched !== null) {
|
9538 | config._d = new Date(+matched[1]);
|
9539 | return;
|
9540 | }
|
9541 |
|
9542 | configFromISO(config);
|
9543 |
|
9544 | if (config._isValid === false) {
|
9545 | delete config._isValid;
|
9546 | } else {
|
9547 | return;
|
9548 | }
|
9549 |
|
9550 | configFromRFC2822(config);
|
9551 |
|
9552 | if (config._isValid === false) {
|
9553 | delete config._isValid;
|
9554 | } else {
|
9555 | return;
|
9556 | }
|
9557 |
|
9558 |
|
9559 | hooks.createFromInputFallback(config);
|
9560 | }
|
9561 |
|
9562 | hooks.createFromInputFallback = deprecate('value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 'discouraged and will be removed in an upcoming major release. Please refer to ' + 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', function (config) {
|
9563 | config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
9564 | });
|
9565 |
|
9566 | hooks.ISO_8601 = function () {};
|
9567 |
|
9568 |
|
9569 | hooks.RFC_2822 = function () {};
|
9570 |
|
9571 |
|
9572 | function configFromStringAndFormat(config) {
|
9573 |
|
9574 | if (config._f === hooks.ISO_8601) {
|
9575 | configFromISO(config);
|
9576 | return;
|
9577 | }
|
9578 |
|
9579 | if (config._f === hooks.RFC_2822) {
|
9580 | configFromRFC2822(config);
|
9581 | return;
|
9582 | }
|
9583 |
|
9584 | config._a = [];
|
9585 | getParsingFlags(config).empty = true;
|
9586 |
|
9587 | var string = '' + config._i,
|
9588 | i,
|
9589 | parsedInput,
|
9590 | tokens,
|
9591 | token,
|
9592 | skipped,
|
9593 | stringLength = string.length,
|
9594 | totalParsedInputLength = 0;
|
9595 | tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
|
9596 |
|
9597 | for (i = 0; i < tokens.length; i++) {
|
9598 | token = tokens[i];
|
9599 | parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
|
9600 |
|
9601 |
|
9602 | if (parsedInput) {
|
9603 | skipped = string.substr(0, string.indexOf(parsedInput));
|
9604 |
|
9605 | if (skipped.length > 0) {
|
9606 | getParsingFlags(config).unusedInput.push(skipped);
|
9607 | }
|
9608 |
|
9609 | string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
9610 | totalParsedInputLength += parsedInput.length;
|
9611 | }
|
9612 |
|
9613 |
|
9614 | if (formatTokenFunctions[token]) {
|
9615 | if (parsedInput) {
|
9616 | getParsingFlags(config).empty = false;
|
9617 | } else {
|
9618 | getParsingFlags(config).unusedTokens.push(token);
|
9619 | }
|
9620 |
|
9621 | addTimeToArrayFromToken(token, parsedInput, config);
|
9622 | } else if (config._strict && !parsedInput) {
|
9623 | getParsingFlags(config).unusedTokens.push(token);
|
9624 | }
|
9625 | }
|
9626 |
|
9627 |
|
9628 | getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
9629 |
|
9630 | if (string.length > 0) {
|
9631 | getParsingFlags(config).unusedInput.push(string);
|
9632 | }
|
9633 |
|
9634 |
|
9635 | if (config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0) {
|
9636 | getParsingFlags(config).bigHour = undefined;
|
9637 | }
|
9638 |
|
9639 | getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
9640 | getParsingFlags(config).meridiem = config._meridiem;
|
9641 |
|
9642 | config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
9643 | configFromArray(config);
|
9644 | checkOverflow(config);
|
9645 | }
|
9646 |
|
9647 | function meridiemFixWrap(locale, hour, meridiem) {
|
9648 | var isPm;
|
9649 |
|
9650 | if (meridiem == null) {
|
9651 |
|
9652 | return hour;
|
9653 | }
|
9654 |
|
9655 | if (locale.meridiemHour != null) {
|
9656 | return locale.meridiemHour(hour, meridiem);
|
9657 | } else if (locale.isPM != null) {
|
9658 |
|
9659 | isPm = locale.isPM(meridiem);
|
9660 |
|
9661 | if (isPm && hour < 12) {
|
9662 | hour += 12;
|
9663 | }
|
9664 |
|
9665 | if (!isPm && hour === 12) {
|
9666 | hour = 0;
|
9667 | }
|
9668 |
|
9669 | return hour;
|
9670 | } else {
|
9671 |
|
9672 | return hour;
|
9673 | }
|
9674 | }
|
9675 |
|
9676 |
|
9677 | function configFromStringAndArray(config) {
|
9678 | var tempConfig, bestMoment, scoreToBeat, i, currentScore;
|
9679 |
|
9680 | if (config._f.length === 0) {
|
9681 | getParsingFlags(config).invalidFormat = true;
|
9682 | config._d = new Date(NaN);
|
9683 | return;
|
9684 | }
|
9685 |
|
9686 | for (i = 0; i < config._f.length; i++) {
|
9687 | currentScore = 0;
|
9688 | tempConfig = copyConfig({}, config);
|
9689 |
|
9690 | if (config._useUTC != null) {
|
9691 | tempConfig._useUTC = config._useUTC;
|
9692 | }
|
9693 |
|
9694 | tempConfig._f = config._f[i];
|
9695 | configFromStringAndFormat(tempConfig);
|
9696 |
|
9697 | if (!isValid(tempConfig)) {
|
9698 | continue;
|
9699 | }
|
9700 |
|
9701 |
|
9702 | currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
9703 |
|
9704 | currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
9705 | getParsingFlags(tempConfig).score = currentScore;
|
9706 |
|
9707 | if (scoreToBeat == null || currentScore < scoreToBeat) {
|
9708 | scoreToBeat = currentScore;
|
9709 | bestMoment = tempConfig;
|
9710 | }
|
9711 | }
|
9712 |
|
9713 | extend(config, bestMoment || tempConfig);
|
9714 | }
|
9715 |
|
9716 | function configFromObject(config) {
|
9717 | if (config._d) {
|
9718 | return;
|
9719 | }
|
9720 |
|
9721 | var i = normalizeObjectUnits(config._i);
|
9722 | config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
|
9723 | return obj && parseInt(obj, 10);
|
9724 | });
|
9725 | configFromArray(config);
|
9726 | }
|
9727 |
|
9728 | function createFromConfig(config) {
|
9729 | var res = new Moment(checkOverflow(prepareConfig(config)));
|
9730 |
|
9731 | if (res._nextDay) {
|
9732 |
|
9733 | res.add(1, 'd');
|
9734 | res._nextDay = undefined;
|
9735 | }
|
9736 |
|
9737 | return res;
|
9738 | }
|
9739 |
|
9740 | function prepareConfig(config) {
|
9741 | var input = config._i,
|
9742 | format = config._f;
|
9743 | config._locale = config._locale || getLocale(config._l);
|
9744 |
|
9745 | if (input === null || format === undefined && input === '') {
|
9746 | return createInvalid({
|
9747 | nullInput: true
|
9748 | });
|
9749 | }
|
9750 |
|
9751 | if (typeof input === 'string') {
|
9752 | config._i = input = config._locale.preparse(input);
|
9753 | }
|
9754 |
|
9755 | if (isMoment(input)) {
|
9756 | return new Moment(checkOverflow(input));
|
9757 | } else if (isDate(input)) {
|
9758 | config._d = input;
|
9759 | } else if (isArray(format)) {
|
9760 | configFromStringAndArray(config);
|
9761 | } else if (format) {
|
9762 | configFromStringAndFormat(config);
|
9763 | } else {
|
9764 | configFromInput(config);
|
9765 | }
|
9766 |
|
9767 | if (!isValid(config)) {
|
9768 | config._d = null;
|
9769 | }
|
9770 |
|
9771 | return config;
|
9772 | }
|
9773 |
|
9774 | function configFromInput(config) {
|
9775 | var input = config._i;
|
9776 |
|
9777 | if (isUndefined(input)) {
|
9778 | config._d = new Date(hooks.now());
|
9779 | } else if (isDate(input)) {
|
9780 | config._d = new Date(input.valueOf());
|
9781 | } else if (typeof input === 'string') {
|
9782 | configFromString(config);
|
9783 | } else if (isArray(input)) {
|
9784 | config._a = map(input.slice(0), function (obj) {
|
9785 | return parseInt(obj, 10);
|
9786 | });
|
9787 | configFromArray(config);
|
9788 | } else if (isObject(input)) {
|
9789 | configFromObject(config);
|
9790 | } else if (isNumber(input)) {
|
9791 |
|
9792 | config._d = new Date(input);
|
9793 | } else {
|
9794 | hooks.createFromInputFallback(config);
|
9795 | }
|
9796 | }
|
9797 |
|
9798 | function createLocalOrUTC(input, format, locale, strict, isUTC) {
|
9799 | var c = {};
|
9800 |
|
9801 | if (locale === true || locale === false) {
|
9802 | strict = locale;
|
9803 | locale = undefined;
|
9804 | }
|
9805 |
|
9806 | if (isObject(input) && isObjectEmpty(input) || isArray(input) && input.length === 0) {
|
9807 | input = undefined;
|
9808 | }
|
9809 |
|
9810 |
|
9811 |
|
9812 | c._isAMomentObject = true;
|
9813 | c._useUTC = c._isUTC = isUTC;
|
9814 | c._l = locale;
|
9815 | c._i = input;
|
9816 | c._f = format;
|
9817 | c._strict = strict;
|
9818 | return createFromConfig(c);
|
9819 | }
|
9820 |
|
9821 | function createLocal(input, format, locale, strict) {
|
9822 | return createLocalOrUTC(input, format, locale, strict, false);
|
9823 | }
|
9824 |
|
9825 | var prototypeMin = deprecate('moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
9826 | var other = createLocal.apply(null, arguments);
|
9827 |
|
9828 | if (this.isValid() && other.isValid()) {
|
9829 | return other < this ? this : other;
|
9830 | } else {
|
9831 | return createInvalid();
|
9832 | }
|
9833 | });
|
9834 | var prototypeMax = deprecate('moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
9835 | var other = createLocal.apply(null, arguments);
|
9836 |
|
9837 | if (this.isValid() && other.isValid()) {
|
9838 | return other > this ? this : other;
|
9839 | } else {
|
9840 | return createInvalid();
|
9841 | }
|
9842 | });
|
9843 |
|
9844 |
|
9845 |
|
9846 |
|
9847 |
|
9848 | function pickBy(fn, moments) {
|
9849 | var res, i;
|
9850 |
|
9851 | if (moments.length === 1 && isArray(moments[0])) {
|
9852 | moments = moments[0];
|
9853 | }
|
9854 |
|
9855 | if (!moments.length) {
|
9856 | return createLocal();
|
9857 | }
|
9858 |
|
9859 | res = moments[0];
|
9860 |
|
9861 | for (i = 1; i < moments.length; ++i) {
|
9862 | if (!moments[i].isValid() || moments[i][fn](res)) {
|
9863 | res = moments[i];
|
9864 | }
|
9865 | }
|
9866 |
|
9867 | return res;
|
9868 | }
|
9869 |
|
9870 |
|
9871 | function min() {
|
9872 | var args = [].slice.call(arguments, 0);
|
9873 | return pickBy('isBefore', args);
|
9874 | }
|
9875 |
|
9876 | function max() {
|
9877 | var args = [].slice.call(arguments, 0);
|
9878 | return pickBy('isAfter', args);
|
9879 | }
|
9880 |
|
9881 | var now = function () {
|
9882 | return Date.now ? Date.now() : +new Date();
|
9883 | };
|
9884 |
|
9885 | var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
9886 |
|
9887 | function isDurationValid(m) {
|
9888 | for (var key in m) {
|
9889 | if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
|
9890 | return false;
|
9891 | }
|
9892 | }
|
9893 |
|
9894 | var unitHasDecimal = false;
|
9895 |
|
9896 | for (var i = 0; i < ordering.length; ++i) {
|
9897 | if (m[ordering[i]]) {
|
9898 | if (unitHasDecimal) {
|
9899 | return false;
|
9900 | }
|
9901 |
|
9902 | if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
|
9903 | unitHasDecimal = true;
|
9904 | }
|
9905 | }
|
9906 | }
|
9907 |
|
9908 | return true;
|
9909 | }
|
9910 |
|
9911 | function isValid$1() {
|
9912 | return this._isValid;
|
9913 | }
|
9914 |
|
9915 | function createInvalid$1() {
|
9916 | return createDuration(NaN);
|
9917 | }
|
9918 |
|
9919 | function Duration(duration) {
|
9920 | var normalizedInput = normalizeObjectUnits(duration),
|
9921 | years = normalizedInput.year || 0,
|
9922 | quarters = normalizedInput.quarter || 0,
|
9923 | months = normalizedInput.month || 0,
|
9924 | weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
9925 | days = normalizedInput.day || 0,
|
9926 | hours = normalizedInput.hour || 0,
|
9927 | minutes = normalizedInput.minute || 0,
|
9928 | seconds = normalizedInput.second || 0,
|
9929 | milliseconds = normalizedInput.millisecond || 0;
|
9930 | this._isValid = isDurationValid(normalizedInput);
|
9931 |
|
9932 | this._milliseconds = +milliseconds + seconds * 1e3 +
|
9933 | minutes * 6e4 +
|
9934 | hours * 1000 * 60 * 60;
|
9935 |
|
9936 |
|
9937 |
|
9938 | this._days = +days + weeks * 7;
|
9939 |
|
9940 |
|
9941 |
|
9942 | this._months = +months + quarters * 3 + years * 12;
|
9943 | this._data = {};
|
9944 | this._locale = getLocale();
|
9945 |
|
9946 | this._bubble();
|
9947 | }
|
9948 |
|
9949 | function isDuration(obj) {
|
9950 | return obj instanceof Duration;
|
9951 | }
|
9952 |
|
9953 | function absRound(number) {
|
9954 | if (number < 0) {
|
9955 | return Math.round(-1 * number) * -1;
|
9956 | } else {
|
9957 | return Math.round(number);
|
9958 | }
|
9959 | }
|
9960 |
|
9961 |
|
9962 | function offset(token, separator) {
|
9963 | addFormatToken(token, 0, 0, function () {
|
9964 | var offset = this.utcOffset();
|
9965 | var sign = '+';
|
9966 |
|
9967 | if (offset < 0) {
|
9968 | offset = -offset;
|
9969 | sign = '-';
|
9970 | }
|
9971 |
|
9972 | return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~offset % 60, 2);
|
9973 | });
|
9974 | }
|
9975 |
|
9976 | offset('Z', ':');
|
9977 | offset('ZZ', '');
|
9978 |
|
9979 | addRegexToken('Z', matchShortOffset);
|
9980 | addRegexToken('ZZ', matchShortOffset);
|
9981 | addParseToken(['Z', 'ZZ'], function (input, array, config) {
|
9982 | config._useUTC = true;
|
9983 | config._tzm = offsetFromString(matchShortOffset, input);
|
9984 | });
|
9985 |
|
9986 |
|
9987 |
|
9988 |
|
9989 | var chunkOffset = /([\+\-]|\d\d)/gi;
|
9990 |
|
9991 | function offsetFromString(matcher, string) {
|
9992 | var matches = (string || '').match(matcher);
|
9993 |
|
9994 | if (matches === null) {
|
9995 | return null;
|
9996 | }
|
9997 |
|
9998 | var chunk = matches[matches.length - 1] || [];
|
9999 | var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
|
10000 | var minutes = +(parts[1] * 60) + toInt(parts[2]);
|
10001 | return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
|
10002 | }
|
10003 |
|
10004 |
|
10005 | function cloneWithOffset(input, model) {
|
10006 | var res, diff;
|
10007 |
|
10008 | if (model._isUTC) {
|
10009 | res = model.clone();
|
10010 | diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
|
10011 |
|
10012 | res._d.setTime(res._d.valueOf() + diff);
|
10013 |
|
10014 | hooks.updateOffset(res, false);
|
10015 | return res;
|
10016 | } else {
|
10017 | return createLocal(input).local();
|
10018 | }
|
10019 | }
|
10020 |
|
10021 | function getDateOffset(m) {
|
10022 |
|
10023 |
|
10024 | return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
|
10025 | }
|
10026 |
|
10027 |
|
10028 |
|
10029 |
|
10030 | hooks.updateOffset = function () {};
|
10031 |
|
10032 |
|
10033 |
|
10034 |
|
10035 |
|
10036 |
|
10037 |
|
10038 |
|
10039 |
|
10040 |
|
10041 |
|
10042 |
|
10043 | function getSetOffset(input, keepLocalTime, keepMinutes) {
|
10044 | var offset = this._offset || 0,
|
10045 | localAdjust;
|
10046 |
|
10047 | if (!this.isValid()) {
|
10048 | return input != null ? this : NaN;
|
10049 | }
|
10050 |
|
10051 | if (input != null) {
|
10052 | if (typeof input === 'string') {
|
10053 | input = offsetFromString(matchShortOffset, input);
|
10054 |
|
10055 | if (input === null) {
|
10056 | return this;
|
10057 | }
|
10058 | } else if (Math.abs(input) < 16 && !keepMinutes) {
|
10059 | input = input * 60;
|
10060 | }
|
10061 |
|
10062 | if (!this._isUTC && keepLocalTime) {
|
10063 | localAdjust = getDateOffset(this);
|
10064 | }
|
10065 |
|
10066 | this._offset = input;
|
10067 | this._isUTC = true;
|
10068 |
|
10069 | if (localAdjust != null) {
|
10070 | this.add(localAdjust, 'm');
|
10071 | }
|
10072 |
|
10073 | if (offset !== input) {
|
10074 | if (!keepLocalTime || this._changeInProgress) {
|
10075 | addSubtract(this, createDuration(input - offset, 'm'), 1, false);
|
10076 | } else if (!this._changeInProgress) {
|
10077 | this._changeInProgress = true;
|
10078 | hooks.updateOffset(this, true);
|
10079 | this._changeInProgress = null;
|
10080 | }
|
10081 | }
|
10082 |
|
10083 | return this;
|
10084 | } else {
|
10085 | return this._isUTC ? offset : getDateOffset(this);
|
10086 | }
|
10087 | }
|
10088 |
|
10089 | function getSetZone(input, keepLocalTime) {
|
10090 | if (input != null) {
|
10091 | if (typeof input !== 'string') {
|
10092 | input = -input;
|
10093 | }
|
10094 |
|
10095 | this.utcOffset(input, keepLocalTime);
|
10096 | return this;
|
10097 | } else {
|
10098 | return -this.utcOffset();
|
10099 | }
|
10100 | }
|
10101 |
|
10102 | function setOffsetToUTC(keepLocalTime) {
|
10103 | return this.utcOffset(0, keepLocalTime);
|
10104 | }
|
10105 |
|
10106 | function setOffsetToLocal(keepLocalTime) {
|
10107 | if (this._isUTC) {
|
10108 | this.utcOffset(0, keepLocalTime);
|
10109 | this._isUTC = false;
|
10110 |
|
10111 | if (keepLocalTime) {
|
10112 | this.subtract(getDateOffset(this), 'm');
|
10113 | }
|
10114 | }
|
10115 |
|
10116 | return this;
|
10117 | }
|
10118 |
|
10119 | function setOffsetToParsedOffset() {
|
10120 | if (this._tzm != null) {
|
10121 | this.utcOffset(this._tzm, false, true);
|
10122 | } else if (typeof this._i === 'string') {
|
10123 | var tZone = offsetFromString(matchOffset, this._i);
|
10124 |
|
10125 | if (tZone != null) {
|
10126 | this.utcOffset(tZone);
|
10127 | } else {
|
10128 | this.utcOffset(0, true);
|
10129 | }
|
10130 | }
|
10131 |
|
10132 | return this;
|
10133 | }
|
10134 |
|
10135 | function hasAlignedHourOffset(input) {
|
10136 | if (!this.isValid()) {
|
10137 | return false;
|
10138 | }
|
10139 |
|
10140 | input = input ? createLocal(input).utcOffset() : 0;
|
10141 | return (this.utcOffset() - input) % 60 === 0;
|
10142 | }
|
10143 |
|
10144 | function isDaylightSavingTime() {
|
10145 | return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset();
|
10146 | }
|
10147 |
|
10148 | function isDaylightSavingTimeShifted() {
|
10149 | if (!isUndefined(this._isDSTShifted)) {
|
10150 | return this._isDSTShifted;
|
10151 | }
|
10152 |
|
10153 | var c = {};
|
10154 | copyConfig(c, this);
|
10155 | c = prepareConfig(c);
|
10156 |
|
10157 | if (c._a) {
|
10158 | var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
|
10159 | this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0;
|
10160 | } else {
|
10161 | this._isDSTShifted = false;
|
10162 | }
|
10163 |
|
10164 | return this._isDSTShifted;
|
10165 | }
|
10166 |
|
10167 | function isLocal() {
|
10168 | return this.isValid() ? !this._isUTC : false;
|
10169 | }
|
10170 |
|
10171 | function isUtcOffset() {
|
10172 | return this.isValid() ? this._isUTC : false;
|
10173 | }
|
10174 |
|
10175 | function isUtc() {
|
10176 | return this.isValid() ? this._isUTC && this._offset === 0 : false;
|
10177 | }
|
10178 |
|
10179 |
|
10180 | var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
|
10181 |
|
10182 |
|
10183 |
|
10184 | var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
|
10185 |
|
10186 | function createDuration(input, key) {
|
10187 | var duration = input,
|
10188 |
|
10189 | match = null,
|
10190 | sign,
|
10191 | ret,
|
10192 | diffRes;
|
10193 |
|
10194 | if (isDuration(input)) {
|
10195 | duration = {
|
10196 | ms: input._milliseconds,
|
10197 | d: input._days,
|
10198 | M: input._months
|
10199 | };
|
10200 | } else if (isNumber(input)) {
|
10201 | duration = {};
|
10202 |
|
10203 | if (key) {
|
10204 | duration[key] = input;
|
10205 | } else {
|
10206 | duration.milliseconds = input;
|
10207 | }
|
10208 | } else if (!!(match = aspNetRegex.exec(input))) {
|
10209 | sign = match[1] === '-' ? -1 : 1;
|
10210 | duration = {
|
10211 | y: 0,
|
10212 | d: toInt(match[DATE]) * sign,
|
10213 | h: toInt(match[HOUR]) * sign,
|
10214 | m: toInt(match[MINUTE]) * sign,
|
10215 | s: toInt(match[SECOND]) * sign,
|
10216 | ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign
|
10217 |
|
10218 | };
|
10219 | } else if (!!(match = isoRegex.exec(input))) {
|
10220 | sign = match[1] === '-' ? -1 : 1;
|
10221 | duration = {
|
10222 | y: parseIso(match[2], sign),
|
10223 | M: parseIso(match[3], sign),
|
10224 | w: parseIso(match[4], sign),
|
10225 | d: parseIso(match[5], sign),
|
10226 | h: parseIso(match[6], sign),
|
10227 | m: parseIso(match[7], sign),
|
10228 | s: parseIso(match[8], sign)
|
10229 | };
|
10230 | } else if (duration == null) {
|
10231 |
|
10232 | duration = {};
|
10233 | } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
|
10234 | diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
|
10235 | duration = {};
|
10236 | duration.ms = diffRes.milliseconds;
|
10237 | duration.M = diffRes.months;
|
10238 | }
|
10239 |
|
10240 | ret = new Duration(duration);
|
10241 |
|
10242 | if (isDuration(input) && hasOwnProp(input, '_locale')) {
|
10243 | ret._locale = input._locale;
|
10244 | }
|
10245 |
|
10246 | return ret;
|
10247 | }
|
10248 |
|
10249 | createDuration.fn = Duration.prototype;
|
10250 | createDuration.invalid = createInvalid$1;
|
10251 |
|
10252 | function parseIso(inp, sign) {
|
10253 |
|
10254 |
|
10255 |
|
10256 | var res = inp && parseFloat(inp.replace(',', '.'));
|
10257 |
|
10258 | return (isNaN(res) ? 0 : res) * sign;
|
10259 | }
|
10260 |
|
10261 | function positiveMomentsDifference(base, other) {
|
10262 | var res = {};
|
10263 | res.months = other.month() - base.month() + (other.year() - base.year()) * 12;
|
10264 |
|
10265 | if (base.clone().add(res.months, 'M').isAfter(other)) {
|
10266 | --res.months;
|
10267 | }
|
10268 |
|
10269 | res.milliseconds = +other - +base.clone().add(res.months, 'M');
|
10270 | return res;
|
10271 | }
|
10272 |
|
10273 | function momentsDifference(base, other) {
|
10274 | var res;
|
10275 |
|
10276 | if (!(base.isValid() && other.isValid())) {
|
10277 | return {
|
10278 | milliseconds: 0,
|
10279 | months: 0
|
10280 | };
|
10281 | }
|
10282 |
|
10283 | other = cloneWithOffset(other, base);
|
10284 |
|
10285 | if (base.isBefore(other)) {
|
10286 | res = positiveMomentsDifference(base, other);
|
10287 | } else {
|
10288 | res = positiveMomentsDifference(other, base);
|
10289 | res.milliseconds = -res.milliseconds;
|
10290 | res.months = -res.months;
|
10291 | }
|
10292 |
|
10293 | return res;
|
10294 | }
|
10295 |
|
10296 |
|
10297 | function createAdder(direction, name) {
|
10298 | return function (val, period) {
|
10299 | var dur, tmp;
|
10300 |
|
10301 | if (period !== null && !isNaN(+period)) {
|
10302 | deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
|
10303 | tmp = val;
|
10304 | val = period;
|
10305 | period = tmp;
|
10306 | }
|
10307 |
|
10308 | val = typeof val === 'string' ? +val : val;
|
10309 | dur = createDuration(val, period);
|
10310 | addSubtract(this, dur, direction);
|
10311 | return this;
|
10312 | };
|
10313 | }
|
10314 |
|
10315 | function addSubtract(mom, duration, isAdding, updateOffset) {
|
10316 | var milliseconds = duration._milliseconds,
|
10317 | days = absRound(duration._days),
|
10318 | months = absRound(duration._months);
|
10319 |
|
10320 | if (!mom.isValid()) {
|
10321 |
|
10322 | return;
|
10323 | }
|
10324 |
|
10325 | updateOffset = updateOffset == null ? true : updateOffset;
|
10326 |
|
10327 | if (months) {
|
10328 | setMonth(mom, get(mom, 'Month') + months * isAdding);
|
10329 | }
|
10330 |
|
10331 | if (days) {
|
10332 | set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
|
10333 | }
|
10334 |
|
10335 | if (milliseconds) {
|
10336 | mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
10337 | }
|
10338 |
|
10339 | if (updateOffset) {
|
10340 | hooks.updateOffset(mom, days || months);
|
10341 | }
|
10342 | }
|
10343 |
|
10344 | var add = createAdder(1, 'add');
|
10345 | var subtract = createAdder(-1, 'subtract');
|
10346 |
|
10347 | function getCalendarFormat(myMoment, now) {
|
10348 | var diff = myMoment.diff(now, 'days', true);
|
10349 | return diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse';
|
10350 | }
|
10351 |
|
10352 | function calendar$1(time, formats) {
|
10353 |
|
10354 |
|
10355 | var now = time || createLocal(),
|
10356 | sod = cloneWithOffset(now, this).startOf('day'),
|
10357 | format = hooks.calendarFormat(this, sod) || 'sameElse';
|
10358 | var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
|
10359 | return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
|
10360 | }
|
10361 |
|
10362 | function clone() {
|
10363 | return new Moment(this);
|
10364 | }
|
10365 |
|
10366 | function isAfter(input, units) {
|
10367 | var localInput = isMoment(input) ? input : createLocal(input);
|
10368 |
|
10369 | if (!(this.isValid() && localInput.isValid())) {
|
10370 | return false;
|
10371 | }
|
10372 |
|
10373 | units = normalizeUnits(units) || 'millisecond';
|
10374 |
|
10375 | if (units === 'millisecond') {
|
10376 | return this.valueOf() > localInput.valueOf();
|
10377 | } else {
|
10378 | return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
10379 | }
|
10380 | }
|
10381 |
|
10382 | function isBefore(input, units) {
|
10383 | var localInput = isMoment(input) ? input : createLocal(input);
|
10384 |
|
10385 | if (!(this.isValid() && localInput.isValid())) {
|
10386 | return false;
|
10387 | }
|
10388 |
|
10389 | units = normalizeUnits(units) || 'millisecond';
|
10390 |
|
10391 | if (units === 'millisecond') {
|
10392 | return this.valueOf() < localInput.valueOf();
|
10393 | } else {
|
10394 | return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
10395 | }
|
10396 | }
|
10397 |
|
10398 | function isBetween(from, to, units, inclusivity) {
|
10399 | var localFrom = isMoment(from) ? from : createLocal(from),
|
10400 | localTo = isMoment(to) ? to : createLocal(to);
|
10401 |
|
10402 | if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
10403 | return false;
|
10404 | }
|
10405 |
|
10406 | inclusivity = inclusivity || '()';
|
10407 | return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
10408 | }
|
10409 |
|
10410 | function isSame(input, units) {
|
10411 | var localInput = isMoment(input) ? input : createLocal(input),
|
10412 | inputMs;
|
10413 |
|
10414 | if (!(this.isValid() && localInput.isValid())) {
|
10415 | return false;
|
10416 | }
|
10417 |
|
10418 | units = normalizeUnits(units) || 'millisecond';
|
10419 |
|
10420 | if (units === 'millisecond') {
|
10421 | return this.valueOf() === localInput.valueOf();
|
10422 | } else {
|
10423 | inputMs = localInput.valueOf();
|
10424 | return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
10425 | }
|
10426 | }
|
10427 |
|
10428 | function isSameOrAfter(input, units) {
|
10429 | return this.isSame(input, units) || this.isAfter(input, units);
|
10430 | }
|
10431 |
|
10432 | function isSameOrBefore(input, units) {
|
10433 | return this.isSame(input, units) || this.isBefore(input, units);
|
10434 | }
|
10435 |
|
10436 | function diff(input, units, asFloat) {
|
10437 | var that, zoneDelta, output;
|
10438 |
|
10439 | if (!this.isValid()) {
|
10440 | return NaN;
|
10441 | }
|
10442 |
|
10443 | that = cloneWithOffset(input, this);
|
10444 |
|
10445 | if (!that.isValid()) {
|
10446 | return NaN;
|
10447 | }
|
10448 |
|
10449 | zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
|
10450 | units = normalizeUnits(units);
|
10451 |
|
10452 | switch (units) {
|
10453 | case 'year':
|
10454 | output = monthDiff(this, that) / 12;
|
10455 | break;
|
10456 |
|
10457 | case 'month':
|
10458 | output = monthDiff(this, that);
|
10459 | break;
|
10460 |
|
10461 | case 'quarter':
|
10462 | output = monthDiff(this, that) / 3;
|
10463 | break;
|
10464 |
|
10465 | case 'second':
|
10466 | output = (this - that) / 1e3;
|
10467 | break;
|
10468 |
|
10469 |
|
10470 | case 'minute':
|
10471 | output = (this - that) / 6e4;
|
10472 | break;
|
10473 |
|
10474 |
|
10475 | case 'hour':
|
10476 | output = (this - that) / 36e5;
|
10477 | break;
|
10478 |
|
10479 |
|
10480 | case 'day':
|
10481 | output = (this - that - zoneDelta) / 864e5;
|
10482 | break;
|
10483 |
|
10484 |
|
10485 | case 'week':
|
10486 | output = (this - that - zoneDelta) / 6048e5;
|
10487 | break;
|
10488 |
|
10489 |
|
10490 | default:
|
10491 | output = this - that;
|
10492 | }
|
10493 |
|
10494 | return asFloat ? output : absFloor(output);
|
10495 | }
|
10496 |
|
10497 | function monthDiff(a, b) {
|
10498 |
|
10499 | var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
|
10500 |
|
10501 | anchor = a.clone().add(wholeMonthDiff, 'months'),
|
10502 | anchor2,
|
10503 | adjust;
|
10504 |
|
10505 | if (b - anchor < 0) {
|
10506 | anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
|
10507 |
|
10508 | adjust = (b - anchor) / (anchor - anchor2);
|
10509 | } else {
|
10510 | anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
|
10511 |
|
10512 | adjust = (b - anchor) / (anchor2 - anchor);
|
10513 | }
|
10514 |
|
10515 |
|
10516 | return -(wholeMonthDiff + adjust) || 0;
|
10517 | }
|
10518 |
|
10519 | hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
10520 | hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
10521 |
|
10522 | function toString() {
|
10523 | return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
10524 | }
|
10525 |
|
10526 | function toISOString(keepOffset) {
|
10527 | if (!this.isValid()) {
|
10528 | return null;
|
10529 | }
|
10530 |
|
10531 | var utc = keepOffset !== true;
|
10532 | var m = utc ? this.clone().utc() : this;
|
10533 |
|
10534 | if (m.year() < 0 || m.year() > 9999) {
|
10535 | return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
10536 | }
|
10537 |
|
10538 | if (isFunction(Date.prototype.toISOString)) {
|
10539 |
|
10540 | if (utc) {
|
10541 | return this.toDate().toISOString();
|
10542 | } else {
|
10543 | return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
|
10544 | }
|
10545 | }
|
10546 |
|
10547 | return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
10548 | }
|
10549 | |
10550 |
|
10551 |
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 | function inspect() {
|
10558 | if (!this.isValid()) {
|
10559 | return 'moment.invalid(/* ' + this._i + ' */)';
|
10560 | }
|
10561 |
|
10562 | var func = 'moment';
|
10563 | var zone = '';
|
10564 |
|
10565 | if (!this.isLocal()) {
|
10566 | func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
|
10567 | zone = 'Z';
|
10568 | }
|
10569 |
|
10570 | var prefix = '[' + func + '("]';
|
10571 | var year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
|
10572 | var datetime = '-MM-DD[T]HH:mm:ss.SSS';
|
10573 | var suffix = zone + '[")]';
|
10574 | return this.format(prefix + year + datetime + suffix);
|
10575 | }
|
10576 |
|
10577 | function format(inputString) {
|
10578 | if (!inputString) {
|
10579 | inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
|
10580 | }
|
10581 |
|
10582 | var output = formatMoment(this, inputString);
|
10583 | return this.localeData().postformat(output);
|
10584 | }
|
10585 |
|
10586 | function from(time, withoutSuffix) {
|
10587 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
10588 | return createDuration({
|
10589 | to: this,
|
10590 | from: time
|
10591 | }).locale(this.locale()).humanize(!withoutSuffix);
|
10592 | } else {
|
10593 | return this.localeData().invalidDate();
|
10594 | }
|
10595 | }
|
10596 |
|
10597 | function fromNow(withoutSuffix) {
|
10598 | return this.from(createLocal(), withoutSuffix);
|
10599 | }
|
10600 |
|
10601 | function to(time, withoutSuffix) {
|
10602 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
10603 | return createDuration({
|
10604 | from: this,
|
10605 | to: time
|
10606 | }).locale(this.locale()).humanize(!withoutSuffix);
|
10607 | } else {
|
10608 | return this.localeData().invalidDate();
|
10609 | }
|
10610 | }
|
10611 |
|
10612 | function toNow(withoutSuffix) {
|
10613 | return this.to(createLocal(), withoutSuffix);
|
10614 | }
|
10615 |
|
10616 |
|
10617 |
|
10618 |
|
10619 | function locale(key) {
|
10620 | var newLocaleData;
|
10621 |
|
10622 | if (key === undefined) {
|
10623 | return this._locale._abbr;
|
10624 | } else {
|
10625 | newLocaleData = getLocale(key);
|
10626 |
|
10627 | if (newLocaleData != null) {
|
10628 | this._locale = newLocaleData;
|
10629 | }
|
10630 |
|
10631 | return this;
|
10632 | }
|
10633 | }
|
10634 |
|
10635 | var lang = deprecate('moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', function (key) {
|
10636 | if (key === undefined) {
|
10637 | return this.localeData();
|
10638 | } else {
|
10639 | return this.locale(key);
|
10640 | }
|
10641 | });
|
10642 |
|
10643 | function localeData() {
|
10644 | return this._locale;
|
10645 | }
|
10646 |
|
10647 | var MS_PER_SECOND = 1000;
|
10648 | var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
10649 | var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
10650 | var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
10651 |
|
10652 | function mod$1(dividend, divisor) {
|
10653 | return (dividend % divisor + divisor) % divisor;
|
10654 | }
|
10655 |
|
10656 | function localStartOfDate(y, m, d) {
|
10657 |
|
10658 | if (y < 100 && y >= 0) {
|
10659 |
|
10660 | return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
10661 | } else {
|
10662 | return new Date(y, m, d).valueOf();
|
10663 | }
|
10664 | }
|
10665 |
|
10666 | function utcStartOfDate(y, m, d) {
|
10667 |
|
10668 | if (y < 100 && y >= 0) {
|
10669 |
|
10670 | return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
10671 | } else {
|
10672 | return Date.UTC(y, m, d);
|
10673 | }
|
10674 | }
|
10675 |
|
10676 | function startOf(units) {
|
10677 | var time;
|
10678 | units = normalizeUnits(units);
|
10679 |
|
10680 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
10681 | return this;
|
10682 | }
|
10683 |
|
10684 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
10685 |
|
10686 | switch (units) {
|
10687 | case 'year':
|
10688 | time = startOfDate(this.year(), 0, 1);
|
10689 | break;
|
10690 |
|
10691 | case 'quarter':
|
10692 | time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
10693 | break;
|
10694 |
|
10695 | case 'month':
|
10696 | time = startOfDate(this.year(), this.month(), 1);
|
10697 | break;
|
10698 |
|
10699 | case 'week':
|
10700 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
10701 | break;
|
10702 |
|
10703 | case 'isoWeek':
|
10704 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
10705 | break;
|
10706 |
|
10707 | case 'day':
|
10708 | case 'date':
|
10709 | time = startOfDate(this.year(), this.month(), this.date());
|
10710 | break;
|
10711 |
|
10712 | case 'hour':
|
10713 | time = this._d.valueOf();
|
10714 | time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
10715 | break;
|
10716 |
|
10717 | case 'minute':
|
10718 | time = this._d.valueOf();
|
10719 | time -= mod$1(time, MS_PER_MINUTE);
|
10720 | break;
|
10721 |
|
10722 | case 'second':
|
10723 | time = this._d.valueOf();
|
10724 | time -= mod$1(time, MS_PER_SECOND);
|
10725 | break;
|
10726 | }
|
10727 |
|
10728 | this._d.setTime(time);
|
10729 |
|
10730 | hooks.updateOffset(this, true);
|
10731 | return this;
|
10732 | }
|
10733 |
|
10734 | function endOf(units) {
|
10735 | var time;
|
10736 | units = normalizeUnits(units);
|
10737 |
|
10738 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
10739 | return this;
|
10740 | }
|
10741 |
|
10742 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
10743 |
|
10744 | switch (units) {
|
10745 | case 'year':
|
10746 | time = startOfDate(this.year() + 1, 0, 1) - 1;
|
10747 | break;
|
10748 |
|
10749 | case 'quarter':
|
10750 | time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
10751 | break;
|
10752 |
|
10753 | case 'month':
|
10754 | time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
10755 | break;
|
10756 |
|
10757 | case 'week':
|
10758 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
10759 | break;
|
10760 |
|
10761 | case 'isoWeek':
|
10762 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
10763 | break;
|
10764 |
|
10765 | case 'day':
|
10766 | case 'date':
|
10767 | time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
10768 | break;
|
10769 |
|
10770 | case 'hour':
|
10771 | time = this._d.valueOf();
|
10772 | time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
10773 | break;
|
10774 |
|
10775 | case 'minute':
|
10776 | time = this._d.valueOf();
|
10777 | time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
10778 | break;
|
10779 |
|
10780 | case 'second':
|
10781 | time = this._d.valueOf();
|
10782 | time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
10783 | break;
|
10784 | }
|
10785 |
|
10786 | this._d.setTime(time);
|
10787 |
|
10788 | hooks.updateOffset(this, true);
|
10789 | return this;
|
10790 | }
|
10791 |
|
10792 | function valueOf() {
|
10793 | return this._d.valueOf() - (this._offset || 0) * 60000;
|
10794 | }
|
10795 |
|
10796 | function unix() {
|
10797 | return Math.floor(this.valueOf() / 1000);
|
10798 | }
|
10799 |
|
10800 | function toDate() {
|
10801 | return new Date(this.valueOf());
|
10802 | }
|
10803 |
|
10804 | function toArray() {
|
10805 | var m = this;
|
10806 | return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
|
10807 | }
|
10808 |
|
10809 | function toObject() {
|
10810 | var m = this;
|
10811 | return {
|
10812 | years: m.year(),
|
10813 | months: m.month(),
|
10814 | date: m.date(),
|
10815 | hours: m.hours(),
|
10816 | minutes: m.minutes(),
|
10817 | seconds: m.seconds(),
|
10818 | milliseconds: m.milliseconds()
|
10819 | };
|
10820 | }
|
10821 |
|
10822 | function toJSON() {
|
10823 |
|
10824 | return this.isValid() ? this.toISOString() : null;
|
10825 | }
|
10826 |
|
10827 | function isValid$2() {
|
10828 | return isValid(this);
|
10829 | }
|
10830 |
|
10831 | function parsingFlags() {
|
10832 | return extend({}, getParsingFlags(this));
|
10833 | }
|
10834 |
|
10835 | function invalidAt() {
|
10836 | return getParsingFlags(this).overflow;
|
10837 | }
|
10838 |
|
10839 | function creationData() {
|
10840 | return {
|
10841 | input: this._i,
|
10842 | format: this._f,
|
10843 | locale: this._locale,
|
10844 | isUTC: this._isUTC,
|
10845 | strict: this._strict
|
10846 | };
|
10847 | }
|
10848 |
|
10849 |
|
10850 | addFormatToken(0, ['gg', 2], 0, function () {
|
10851 | return this.weekYear() % 100;
|
10852 | });
|
10853 | addFormatToken(0, ['GG', 2], 0, function () {
|
10854 | return this.isoWeekYear() % 100;
|
10855 | });
|
10856 |
|
10857 | function addWeekYearFormatToken(token, getter) {
|
10858 | addFormatToken(0, [token, token.length], 0, getter);
|
10859 | }
|
10860 |
|
10861 | addWeekYearFormatToken('gggg', 'weekYear');
|
10862 | addWeekYearFormatToken('ggggg', 'weekYear');
|
10863 | addWeekYearFormatToken('GGGG', 'isoWeekYear');
|
10864 | addWeekYearFormatToken('GGGGG', 'isoWeekYear');
|
10865 |
|
10866 | addUnitAlias('weekYear', 'gg');
|
10867 | addUnitAlias('isoWeekYear', 'GG');
|
10868 |
|
10869 | addUnitPriority('weekYear', 1);
|
10870 | addUnitPriority('isoWeekYear', 1);
|
10871 |
|
10872 | addRegexToken('G', matchSigned);
|
10873 | addRegexToken('g', matchSigned);
|
10874 | addRegexToken('GG', match1to2, match2);
|
10875 | addRegexToken('gg', match1to2, match2);
|
10876 | addRegexToken('GGGG', match1to4, match4);
|
10877 | addRegexToken('gggg', match1to4, match4);
|
10878 | addRegexToken('GGGGG', match1to6, match6);
|
10879 | addRegexToken('ggggg', match1to6, match6);
|
10880 | addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
|
10881 | week[token.substr(0, 2)] = toInt(input);
|
10882 | });
|
10883 | addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
|
10884 | week[token] = hooks.parseTwoDigitYear(input);
|
10885 | });
|
10886 |
|
10887 | function getSetWeekYear(input) {
|
10888 | return getSetWeekYearHelper.call(this, input, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy);
|
10889 | }
|
10890 |
|
10891 | function getSetISOWeekYear(input) {
|
10892 | return getSetWeekYearHelper.call(this, input, this.isoWeek(), this.isoWeekday(), 1, 4);
|
10893 | }
|
10894 |
|
10895 | function getISOWeeksInYear() {
|
10896 | return weeksInYear(this.year(), 1, 4);
|
10897 | }
|
10898 |
|
10899 | function getWeeksInYear() {
|
10900 | var weekInfo = this.localeData()._week;
|
10901 |
|
10902 | return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
10903 | }
|
10904 |
|
10905 | function getSetWeekYearHelper(input, week, weekday, dow, doy) {
|
10906 | var weeksTarget;
|
10907 |
|
10908 | if (input == null) {
|
10909 | return weekOfYear(this, dow, doy).year;
|
10910 | } else {
|
10911 | weeksTarget = weeksInYear(input, dow, doy);
|
10912 |
|
10913 | if (week > weeksTarget) {
|
10914 | week = weeksTarget;
|
10915 | }
|
10916 |
|
10917 | return setWeekAll.call(this, input, week, weekday, dow, doy);
|
10918 | }
|
10919 | }
|
10920 |
|
10921 | function setWeekAll(weekYear, week, weekday, dow, doy) {
|
10922 | var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
|
10923 | date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
|
10924 | this.year(date.getUTCFullYear());
|
10925 | this.month(date.getUTCMonth());
|
10926 | this.date(date.getUTCDate());
|
10927 | return this;
|
10928 | }
|
10929 |
|
10930 |
|
10931 | addFormatToken('Q', 0, 'Qo', 'quarter');
|
10932 |
|
10933 | addUnitAlias('quarter', 'Q');
|
10934 |
|
10935 | addUnitPriority('quarter', 7);
|
10936 |
|
10937 | addRegexToken('Q', match1);
|
10938 | addParseToken('Q', function (input, array) {
|
10939 | array[MONTH] = (toInt(input) - 1) * 3;
|
10940 | });
|
10941 |
|
10942 | function getSetQuarter(input) {
|
10943 | return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
10944 | }
|
10945 |
|
10946 |
|
10947 | addFormatToken('D', ['DD', 2], 'Do', 'date');
|
10948 |
|
10949 | addUnitAlias('date', 'D');
|
10950 |
|
10951 | addUnitPriority('date', 9);
|
10952 |
|
10953 | addRegexToken('D', match1to2);
|
10954 | addRegexToken('DD', match1to2, match2);
|
10955 | addRegexToken('Do', function (isStrict, locale) {
|
10956 |
|
10957 | return isStrict ? locale._dayOfMonthOrdinalParse || locale._ordinalParse : locale._dayOfMonthOrdinalParseLenient;
|
10958 | });
|
10959 | addParseToken(['D', 'DD'], DATE);
|
10960 | addParseToken('Do', function (input, array) {
|
10961 | array[DATE] = toInt(input.match(match1to2)[0]);
|
10962 | });
|
10963 |
|
10964 | var getSetDayOfMonth = makeGetSet('Date', true);
|
10965 |
|
10966 | addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
10967 |
|
10968 | addUnitAlias('dayOfYear', 'DDD');
|
10969 |
|
10970 | addUnitPriority('dayOfYear', 4);
|
10971 |
|
10972 | addRegexToken('DDD', match1to3);
|
10973 | addRegexToken('DDDD', match3);
|
10974 | addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
10975 | config._dayOfYear = toInt(input);
|
10976 | });
|
10977 |
|
10978 |
|
10979 | function getSetDayOfYear(input) {
|
10980 | var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
10981 | return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
|
10982 | }
|
10983 |
|
10984 |
|
10985 | addFormatToken('m', ['mm', 2], 0, 'minute');
|
10986 |
|
10987 | addUnitAlias('minute', 'm');
|
10988 |
|
10989 | addUnitPriority('minute', 14);
|
10990 |
|
10991 | addRegexToken('m', match1to2);
|
10992 | addRegexToken('mm', match1to2, match2);
|
10993 | addParseToken(['m', 'mm'], MINUTE);
|
10994 |
|
10995 | var getSetMinute = makeGetSet('Minutes', false);
|
10996 |
|
10997 | addFormatToken('s', ['ss', 2], 0, 'second');
|
10998 |
|
10999 | addUnitAlias('second', 's');
|
11000 |
|
11001 | addUnitPriority('second', 15);
|
11002 |
|
11003 | addRegexToken('s', match1to2);
|
11004 | addRegexToken('ss', match1to2, match2);
|
11005 | addParseToken(['s', 'ss'], SECOND);
|
11006 |
|
11007 | var getSetSecond = makeGetSet('Seconds', false);
|
11008 |
|
11009 | addFormatToken('S', 0, 0, function () {
|
11010 | return ~~(this.millisecond() / 100);
|
11011 | });
|
11012 | addFormatToken(0, ['SS', 2], 0, function () {
|
11013 | return ~~(this.millisecond() / 10);
|
11014 | });
|
11015 | addFormatToken(0, ['SSS', 3], 0, 'millisecond');
|
11016 | addFormatToken(0, ['SSSS', 4], 0, function () {
|
11017 | return this.millisecond() * 10;
|
11018 | });
|
11019 | addFormatToken(0, ['SSSSS', 5], 0, function () {
|
11020 | return this.millisecond() * 100;
|
11021 | });
|
11022 | addFormatToken(0, ['SSSSSS', 6], 0, function () {
|
11023 | return this.millisecond() * 1000;
|
11024 | });
|
11025 | addFormatToken(0, ['SSSSSSS', 7], 0, function () {
|
11026 | return this.millisecond() * 10000;
|
11027 | });
|
11028 | addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
|
11029 | return this.millisecond() * 100000;
|
11030 | });
|
11031 | addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
|
11032 | return this.millisecond() * 1000000;
|
11033 | });
|
11034 |
|
11035 | addUnitAlias('millisecond', 'ms');
|
11036 |
|
11037 | addUnitPriority('millisecond', 16);
|
11038 |
|
11039 | addRegexToken('S', match1to3, match1);
|
11040 | addRegexToken('SS', match1to3, match2);
|
11041 | addRegexToken('SSS', match1to3, match3);
|
11042 | var token;
|
11043 |
|
11044 | for (token = 'SSSS'; token.length <= 9; token += 'S') {
|
11045 | addRegexToken(token, matchUnsigned);
|
11046 | }
|
11047 |
|
11048 | function parseMs(input, array) {
|
11049 | array[MILLISECOND] = toInt(('0.' + input) * 1000);
|
11050 | }
|
11051 |
|
11052 | for (token = 'S'; token.length <= 9; token += 'S') {
|
11053 | addParseToken(token, parseMs);
|
11054 | }
|
11055 |
|
11056 |
|
11057 | var getSetMillisecond = makeGetSet('Milliseconds', false);
|
11058 |
|
11059 | addFormatToken('z', 0, 0, 'zoneAbbr');
|
11060 | addFormatToken('zz', 0, 0, 'zoneName');
|
11061 |
|
11062 | function getZoneAbbr() {
|
11063 | return this._isUTC ? 'UTC' : '';
|
11064 | }
|
11065 |
|
11066 | function getZoneName() {
|
11067 | return this._isUTC ? 'Coordinated Universal Time' : '';
|
11068 | }
|
11069 |
|
11070 | var proto = Moment.prototype;
|
11071 | proto.add = add;
|
11072 | proto.calendar = calendar$1;
|
11073 | proto.clone = clone;
|
11074 | proto.diff = diff;
|
11075 | proto.endOf = endOf;
|
11076 | proto.format = format;
|
11077 | proto.from = from;
|
11078 | proto.fromNow = fromNow;
|
11079 | proto.to = to;
|
11080 | proto.toNow = toNow;
|
11081 | proto.get = stringGet;
|
11082 | proto.invalidAt = invalidAt;
|
11083 | proto.isAfter = isAfter;
|
11084 | proto.isBefore = isBefore;
|
11085 | proto.isBetween = isBetween;
|
11086 | proto.isSame = isSame;
|
11087 | proto.isSameOrAfter = isSameOrAfter;
|
11088 | proto.isSameOrBefore = isSameOrBefore;
|
11089 | proto.isValid = isValid$2;
|
11090 | proto.lang = lang;
|
11091 | proto.locale = locale;
|
11092 | proto.localeData = localeData;
|
11093 | proto.max = prototypeMax;
|
11094 | proto.min = prototypeMin;
|
11095 | proto.parsingFlags = parsingFlags;
|
11096 | proto.set = stringSet;
|
11097 | proto.startOf = startOf;
|
11098 | proto.subtract = subtract;
|
11099 | proto.toArray = toArray;
|
11100 | proto.toObject = toObject;
|
11101 | proto.toDate = toDate;
|
11102 | proto.toISOString = toISOString;
|
11103 | proto.inspect = inspect;
|
11104 | proto.toJSON = toJSON;
|
11105 | proto.toString = toString;
|
11106 | proto.unix = unix;
|
11107 | proto.valueOf = valueOf;
|
11108 | proto.creationData = creationData;
|
11109 | proto.year = getSetYear;
|
11110 | proto.isLeapYear = getIsLeapYear;
|
11111 | proto.weekYear = getSetWeekYear;
|
11112 | proto.isoWeekYear = getSetISOWeekYear;
|
11113 | proto.quarter = proto.quarters = getSetQuarter;
|
11114 | proto.month = getSetMonth;
|
11115 | proto.daysInMonth = getDaysInMonth;
|
11116 | proto.week = proto.weeks = getSetWeek;
|
11117 | proto.isoWeek = proto.isoWeeks = getSetISOWeek;
|
11118 | proto.weeksInYear = getWeeksInYear;
|
11119 | proto.isoWeeksInYear = getISOWeeksInYear;
|
11120 | proto.date = getSetDayOfMonth;
|
11121 | proto.day = proto.days = getSetDayOfWeek;
|
11122 | proto.weekday = getSetLocaleDayOfWeek;
|
11123 | proto.isoWeekday = getSetISODayOfWeek;
|
11124 | proto.dayOfYear = getSetDayOfYear;
|
11125 | proto.hour = proto.hours = getSetHour;
|
11126 | proto.minute = proto.minutes = getSetMinute;
|
11127 | proto.second = proto.seconds = getSetSecond;
|
11128 | proto.millisecond = proto.milliseconds = getSetMillisecond;
|
11129 | proto.utcOffset = getSetOffset;
|
11130 | proto.utc = setOffsetToUTC;
|
11131 | proto.local = setOffsetToLocal;
|
11132 | proto.parseZone = setOffsetToParsedOffset;
|
11133 | proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
11134 | proto.isDST = isDaylightSavingTime;
|
11135 | proto.isLocal = isLocal;
|
11136 | proto.isUtcOffset = isUtcOffset;
|
11137 | proto.isUtc = isUtc;
|
11138 | proto.isUTC = isUtc;
|
11139 | proto.zoneAbbr = getZoneAbbr;
|
11140 | proto.zoneName = getZoneName;
|
11141 | proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
11142 | proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
11143 | proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
11144 | proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
|
11145 | proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
|
11146 |
|
11147 | function createUnix(input) {
|
11148 | return createLocal(input * 1000);
|
11149 | }
|
11150 |
|
11151 | function createInZone() {
|
11152 | return createLocal.apply(null, arguments).parseZone();
|
11153 | }
|
11154 |
|
11155 | function preParsePostFormat(string) {
|
11156 | return string;
|
11157 | }
|
11158 |
|
11159 | var proto$1 = Locale.prototype;
|
11160 | proto$1.calendar = calendar;
|
11161 | proto$1.longDateFormat = longDateFormat;
|
11162 | proto$1.invalidDate = invalidDate;
|
11163 | proto$1.ordinal = ordinal;
|
11164 | proto$1.preparse = preParsePostFormat;
|
11165 | proto$1.postformat = preParsePostFormat;
|
11166 | proto$1.relativeTime = relativeTime;
|
11167 | proto$1.pastFuture = pastFuture;
|
11168 | proto$1.set = set;
|
11169 | proto$1.months = localeMonths;
|
11170 | proto$1.monthsShort = localeMonthsShort;
|
11171 | proto$1.monthsParse = localeMonthsParse;
|
11172 | proto$1.monthsRegex = monthsRegex;
|
11173 | proto$1.monthsShortRegex = monthsShortRegex;
|
11174 | proto$1.week = localeWeek;
|
11175 | proto$1.firstDayOfYear = localeFirstDayOfYear;
|
11176 | proto$1.firstDayOfWeek = localeFirstDayOfWeek;
|
11177 | proto$1.weekdays = localeWeekdays;
|
11178 | proto$1.weekdaysMin = localeWeekdaysMin;
|
11179 | proto$1.weekdaysShort = localeWeekdaysShort;
|
11180 | proto$1.weekdaysParse = localeWeekdaysParse;
|
11181 | proto$1.weekdaysRegex = weekdaysRegex;
|
11182 | proto$1.weekdaysShortRegex = weekdaysShortRegex;
|
11183 | proto$1.weekdaysMinRegex = weekdaysMinRegex;
|
11184 | proto$1.isPM = localeIsPM;
|
11185 | proto$1.meridiem = localeMeridiem;
|
11186 |
|
11187 | function get$1(format, index, field, setter) {
|
11188 | var locale = getLocale();
|
11189 | var utc = createUTC().set(setter, index);
|
11190 | return locale[field](utc, format);
|
11191 | }
|
11192 |
|
11193 | function listMonthsImpl(format, index, field) {
|
11194 | if (isNumber(format)) {
|
11195 | index = format;
|
11196 | format = undefined;
|
11197 | }
|
11198 |
|
11199 | format = format || '';
|
11200 |
|
11201 | if (index != null) {
|
11202 | return get$1(format, index, field, 'month');
|
11203 | }
|
11204 |
|
11205 | var i;
|
11206 | var out = [];
|
11207 |
|
11208 | for (i = 0; i < 12; i++) {
|
11209 | out[i] = get$1(format, i, field, 'month');
|
11210 | }
|
11211 |
|
11212 | return out;
|
11213 | } // ()
|
11214 | // (5)
|
11215 | // (fmt, 5)
|
11216 | // (fmt)
|
11217 | // (true)
|
11218 | // (true, 5)
|
11219 | // (true, fmt, 5)
|
11220 | // (true, fmt)
|
11221 |
|
11222 |
|
11223 | function listWeekdaysImpl(localeSorted, format, index, field) {
|
11224 | if (typeof localeSorted === 'boolean') {
|
11225 | if (isNumber(format)) {
|
11226 | index = format;
|
11227 | format = undefined;
|
11228 | }
|
11229 |
|
11230 | format = format || '';
|
11231 | } else {
|
11232 | format = localeSorted;
|
11233 | index = format;
|
11234 | localeSorted = false;
|
11235 |
|
11236 | if (isNumber(format)) {
|
11237 | index = format;
|
11238 | format = undefined;
|
11239 | }
|
11240 |
|
11241 | format = format || '';
|
11242 | }
|
11243 |
|
11244 | var locale = getLocale(),
|
11245 | shift = localeSorted ? locale._week.dow : 0;
|
11246 |
|
11247 | if (index != null) {
|
11248 | return get$1(format, (index + shift) % 7, field, 'day');
|
11249 | }
|
11250 |
|
11251 | var i;
|
11252 | var out = [];
|
11253 |
|
11254 | for (i = 0; i < 7; i++) {
|
11255 | out[i] = get$1(format, (i + shift) % 7, field, 'day');
|
11256 | }
|
11257 |
|
11258 | return out;
|
11259 | }
|
11260 |
|
11261 | function listMonths(format, index) {
|
11262 | return listMonthsImpl(format, index, 'months');
|
11263 | }
|
11264 |
|
11265 | function listMonthsShort(format, index) {
|
11266 | return listMonthsImpl(format, index, 'monthsShort');
|
11267 | }
|
11268 |
|
11269 | function listWeekdays(localeSorted, format, index) {
|
11270 | return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
11271 | }
|
11272 |
|
11273 | function listWeekdaysShort(localeSorted, format, index) {
|
11274 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
11275 | }
|
11276 |
|
11277 | function listWeekdaysMin(localeSorted, format, index) {
|
11278 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
11279 | }
|
11280 |
|
11281 | getSetGlobalLocale('en', {
|
11282 | dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
11283 | ordinal: function (number) {
|
11284 | var b = number % 10,
|
11285 | output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
11286 | return number + output;
|
11287 | }
|
11288 | });
|
11289 |
|
11290 | hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
|
11291 | hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
|
11292 | var mathAbs = Math.abs;
|
11293 |
|
11294 | function abs() {
|
11295 | var data = this._data;
|
11296 | this._milliseconds = mathAbs(this._milliseconds);
|
11297 | this._days = mathAbs(this._days);
|
11298 | this._months = mathAbs(this._months);
|
11299 | data.milliseconds = mathAbs(data.milliseconds);
|
11300 | data.seconds = mathAbs(data.seconds);
|
11301 | data.minutes = mathAbs(data.minutes);
|
11302 | data.hours = mathAbs(data.hours);
|
11303 | data.months = mathAbs(data.months);
|
11304 | data.years = mathAbs(data.years);
|
11305 | return this;
|
11306 | }
|
11307 |
|
11308 | function addSubtract$1(duration, input, value, direction) {
|
11309 | var other = createDuration(input, value);
|
11310 | duration._milliseconds += direction * other._milliseconds;
|
11311 | duration._days += direction * other._days;
|
11312 | duration._months += direction * other._months;
|
11313 | return duration._bubble();
|
11314 | }
|
11315 |
|
11316 |
|
11317 | function add$1(input, value) {
|
11318 | return addSubtract$1(this, input, value, 1);
|
11319 | }
|
11320 |
|
11321 |
|
11322 | function subtract$1(input, value) {
|
11323 | return addSubtract$1(this, input, value, -1);
|
11324 | }
|
11325 |
|
11326 | function absCeil(number) {
|
11327 | if (number < 0) {
|
11328 | return Math.floor(number);
|
11329 | } else {
|
11330 | return Math.ceil(number);
|
11331 | }
|
11332 | }
|
11333 |
|
11334 | function bubble() {
|
11335 | var milliseconds = this._milliseconds;
|
11336 | var days = this._days;
|
11337 | var months = this._months;
|
11338 | var data = this._data;
|
11339 | var seconds, minutes, hours, years, monthsFromDays;
|
11340 |
|
11341 |
|
11342 | if (!(milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0)) {
|
11343 | milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
|
11344 | days = 0;
|
11345 | months = 0;
|
11346 | }
|
11347 |
|
11348 |
|
11349 |
|
11350 | data.milliseconds = milliseconds % 1000;
|
11351 | seconds = absFloor(milliseconds / 1000);
|
11352 | data.seconds = seconds % 60;
|
11353 | minutes = absFloor(seconds / 60);
|
11354 | data.minutes = minutes % 60;
|
11355 | hours = absFloor(minutes / 60);
|
11356 | data.hours = hours % 24;
|
11357 | days += absFloor(hours / 24);
|
11358 |
|
11359 | monthsFromDays = absFloor(daysToMonths(days));
|
11360 | months += monthsFromDays;
|
11361 | days -= absCeil(monthsToDays(monthsFromDays));
|
11362 |
|
11363 | years = absFloor(months / 12);
|
11364 | months %= 12;
|
11365 | data.days = days;
|
11366 | data.months = months;
|
11367 | data.years = years;
|
11368 | return this;
|
11369 | }
|
11370 |
|
11371 | function daysToMonths(days) {
|
11372 |
|
11373 |
|
11374 | return days * 4800 / 146097;
|
11375 | }
|
11376 |
|
11377 | function monthsToDays(months) {
|
11378 |
|
11379 | return months * 146097 / 4800;
|
11380 | }
|
11381 |
|
11382 | function as(units) {
|
11383 | if (!this.isValid()) {
|
11384 | return NaN;
|
11385 | }
|
11386 |
|
11387 | var days;
|
11388 | var months;
|
11389 | var milliseconds = this._milliseconds;
|
11390 | units = normalizeUnits(units);
|
11391 |
|
11392 | if (units === 'month' || units === 'quarter' || units === 'year') {
|
11393 | days = this._days + milliseconds / 864e5;
|
11394 | months = this._months + daysToMonths(days);
|
11395 |
|
11396 | switch (units) {
|
11397 | case 'month':
|
11398 | return months;
|
11399 |
|
11400 | case 'quarter':
|
11401 | return months / 3;
|
11402 |
|
11403 | case 'year':
|
11404 | return months / 12;
|
11405 | }
|
11406 | } else {
|
11407 |
|
11408 | days = this._days + Math.round(monthsToDays(this._months));
|
11409 |
|
11410 | switch (units) {
|
11411 | case 'week':
|
11412 | return days / 7 + milliseconds / 6048e5;
|
11413 |
|
11414 | case 'day':
|
11415 | return days + milliseconds / 864e5;
|
11416 |
|
11417 | case 'hour':
|
11418 | return days * 24 + milliseconds / 36e5;
|
11419 |
|
11420 | case 'minute':
|
11421 | return days * 1440 + milliseconds / 6e4;
|
11422 |
|
11423 | case 'second':
|
11424 | return days * 86400 + milliseconds / 1000;
|
11425 |
|
11426 |
|
11427 | case 'millisecond':
|
11428 | return Math.floor(days * 864e5) + milliseconds;
|
11429 |
|
11430 | default:
|
11431 | throw new Error('Unknown unit ' + units);
|
11432 | }
|
11433 | }
|
11434 | }
|
11435 |
|
11436 |
|
11437 | function valueOf$1() {
|
11438 | if (!this.isValid()) {
|
11439 | return NaN;
|
11440 | }
|
11441 |
|
11442 | return this._milliseconds + this._days * 864e5 + this._months % 12 * 2592e6 + toInt(this._months / 12) * 31536e6;
|
11443 | }
|
11444 |
|
11445 | function makeAs(alias) {
|
11446 | return function () {
|
11447 | return this.as(alias);
|
11448 | };
|
11449 | }
|
11450 |
|
11451 | var asMilliseconds = makeAs('ms');
|
11452 | var asSeconds = makeAs('s');
|
11453 | var asMinutes = makeAs('m');
|
11454 | var asHours = makeAs('h');
|
11455 | var asDays = makeAs('d');
|
11456 | var asWeeks = makeAs('w');
|
11457 | var asMonths = makeAs('M');
|
11458 | var asQuarters = makeAs('Q');
|
11459 | var asYears = makeAs('y');
|
11460 |
|
11461 | function clone$1() {
|
11462 | return createDuration(this);
|
11463 | }
|
11464 |
|
11465 | function get$2(units) {
|
11466 | units = normalizeUnits(units);
|
11467 | return this.isValid() ? this[units + 's']() : NaN;
|
11468 | }
|
11469 |
|
11470 | function makeGetter(name) {
|
11471 | return function () {
|
11472 | return this.isValid() ? this._data[name] : NaN;
|
11473 | };
|
11474 | }
|
11475 |
|
11476 | var milliseconds = makeGetter('milliseconds');
|
11477 | var seconds = makeGetter('seconds');
|
11478 | var minutes = makeGetter('minutes');
|
11479 | var hours = makeGetter('hours');
|
11480 | var days = makeGetter('days');
|
11481 | var months = makeGetter('months');
|
11482 | var years = makeGetter('years');
|
11483 |
|
11484 | function weeks() {
|
11485 | return absFloor(this.days() / 7);
|
11486 | }
|
11487 |
|
11488 | var round = Math.round;
|
11489 | var thresholds = {
|
11490 | ss: 44,
|
11491 |
|
11492 | s: 45,
|
11493 |
|
11494 | m: 45,
|
11495 |
|
11496 | h: 22,
|
11497 |
|
11498 | d: 26,
|
11499 |
|
11500 | M: 11
|
11501 |
|
11502 | };
|
11503 |
|
11504 | function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
11505 | return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
11506 | }
|
11507 |
|
11508 | function relativeTime$1(posNegDuration, withoutSuffix, locale) {
|
11509 | var duration = createDuration(posNegDuration).abs();
|
11510 | var seconds = round(duration.as('s'));
|
11511 | var minutes = round(duration.as('m'));
|
11512 | var hours = round(duration.as('h'));
|
11513 | var days = round(duration.as('d'));
|
11514 | var months = round(duration.as('M'));
|
11515 | var years = round(duration.as('y'));
|
11516 | var a = seconds <= thresholds.ss && ['s', seconds] || seconds < thresholds.s && ['ss', seconds] || minutes <= 1 && ['m'] || minutes < thresholds.m && ['mm', minutes] || hours <= 1 && ['h'] || hours < thresholds.h && ['hh', hours] || days <= 1 && ['d'] || days < thresholds.d && ['dd', days] || months <= 1 && ['M'] || months < thresholds.M && ['MM', months] || years <= 1 && ['y'] || ['yy', years];
|
11517 | a[2] = withoutSuffix;
|
11518 | a[3] = +posNegDuration > 0;
|
11519 | a[4] = locale;
|
11520 | return substituteTimeAgo.apply(null, a);
|
11521 | }
|
11522 |
|
11523 |
|
11524 | function getSetRelativeTimeRounding(roundingFunction) {
|
11525 | if (roundingFunction === undefined) {
|
11526 | return round;
|
11527 | }
|
11528 |
|
11529 | if (typeof roundingFunction === 'function') {
|
11530 | round = roundingFunction;
|
11531 | return true;
|
11532 | }
|
11533 |
|
11534 | return false;
|
11535 | }
|
11536 |
|
11537 |
|
11538 | function getSetRelativeTimeThreshold(threshold, limit) {
|
11539 | if (thresholds[threshold] === undefined) {
|
11540 | return false;
|
11541 | }
|
11542 |
|
11543 | if (limit === undefined) {
|
11544 | return thresholds[threshold];
|
11545 | }
|
11546 |
|
11547 | thresholds[threshold] = limit;
|
11548 |
|
11549 | if (threshold === 's') {
|
11550 | thresholds.ss = limit - 1;
|
11551 | }
|
11552 |
|
11553 | return true;
|
11554 | }
|
11555 |
|
11556 | function humanize(withSuffix) {
|
11557 | if (!this.isValid()) {
|
11558 | return this.localeData().invalidDate();
|
11559 | }
|
11560 |
|
11561 | var locale = this.localeData();
|
11562 | var output = relativeTime$1(this, !withSuffix, locale);
|
11563 |
|
11564 | if (withSuffix) {
|
11565 | output = locale.pastFuture(+this, output);
|
11566 | }
|
11567 |
|
11568 | return locale.postformat(output);
|
11569 | }
|
11570 |
|
11571 | var abs$1 = Math.abs;
|
11572 |
|
11573 | function sign(x) {
|
11574 | return (x > 0) - (x < 0) || +x;
|
11575 | }
|
11576 |
|
11577 | function toISOString$1() {
|
11578 |
|
11579 |
|
11580 |
|
11581 |
|
11582 |
|
11583 |
|
11584 |
|
11585 | if (!this.isValid()) {
|
11586 | return this.localeData().invalidDate();
|
11587 | }
|
11588 |
|
11589 | var seconds = abs$1(this._milliseconds) / 1000;
|
11590 | var days = abs$1(this._days);
|
11591 | var months = abs$1(this._months);
|
11592 | var minutes, hours, years;
|
11593 |
|
11594 | minutes = absFloor(seconds / 60);
|
11595 | hours = absFloor(minutes / 60);
|
11596 | seconds %= 60;
|
11597 | minutes %= 60;
|
11598 |
|
11599 | years = absFloor(months / 12);
|
11600 | months %= 12;
|
11601 |
|
11602 | var Y = years;
|
11603 | var M = months;
|
11604 | var D = days;
|
11605 | var h = hours;
|
11606 | var m = minutes;
|
11607 | var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
|
11608 | var total = this.asSeconds();
|
11609 |
|
11610 | if (!total) {
|
11611 |
|
11612 |
|
11613 | return 'P0D';
|
11614 | }
|
11615 |
|
11616 | var totalSign = total < 0 ? '-' : '';
|
11617 | var ymSign = sign(this._months) !== sign(total) ? '-' : '';
|
11618 | var daysSign = sign(this._days) !== sign(total) ? '-' : '';
|
11619 | var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
|
11620 | return totalSign + 'P' + (Y ? ymSign + Y + 'Y' : '') + (M ? ymSign + M + 'M' : '') + (D ? daysSign + D + 'D' : '') + (h || m || s ? 'T' : '') + (h ? hmsSign + h + 'H' : '') + (m ? hmsSign + m + 'M' : '') + (s ? hmsSign + s + 'S' : '');
|
11621 | }
|
11622 |
|
11623 | var proto$2 = Duration.prototype;
|
11624 | proto$2.isValid = isValid$1;
|
11625 | proto$2.abs = abs;
|
11626 | proto$2.add = add$1;
|
11627 | proto$2.subtract = subtract$1;
|
11628 | proto$2.as = as;
|
11629 | proto$2.asMilliseconds = asMilliseconds;
|
11630 | proto$2.asSeconds = asSeconds;
|
11631 | proto$2.asMinutes = asMinutes;
|
11632 | proto$2.asHours = asHours;
|
11633 | proto$2.asDays = asDays;
|
11634 | proto$2.asWeeks = asWeeks;
|
11635 | proto$2.asMonths = asMonths;
|
11636 | proto$2.asQuarters = asQuarters;
|
11637 | proto$2.asYears = asYears;
|
11638 | proto$2.valueOf = valueOf$1;
|
11639 | proto$2._bubble = bubble;
|
11640 | proto$2.clone = clone$1;
|
11641 | proto$2.get = get$2;
|
11642 | proto$2.milliseconds = milliseconds;
|
11643 | proto$2.seconds = seconds;
|
11644 | proto$2.minutes = minutes;
|
11645 | proto$2.hours = hours;
|
11646 | proto$2.days = days;
|
11647 | proto$2.weeks = weeks;
|
11648 | proto$2.months = months;
|
11649 | proto$2.years = years;
|
11650 | proto$2.humanize = humanize;
|
11651 | proto$2.toISOString = toISOString$1;
|
11652 | proto$2.toString = toISOString$1;
|
11653 | proto$2.toJSON = toISOString$1;
|
11654 | proto$2.locale = locale;
|
11655 | proto$2.localeData = localeData;
|
11656 | proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
|
11657 | proto$2.lang = lang; // Side effect imports
|
11658 | // FORMATTING
|
11659 |
|
11660 | addFormatToken('X', 0, 0, 'unix');
|
11661 | addFormatToken('x', 0, 0, 'valueOf'); // PARSING
|
11662 |
|
11663 | addRegexToken('x', matchSigned);
|
11664 | addRegexToken('X', matchTimestamp);
|
11665 | addParseToken('X', function (input, array, config) {
|
11666 | config._d = new Date(parseFloat(input, 10) * 1000);
|
11667 | });
|
11668 | addParseToken('x', function (input, array, config) {
|
11669 | config._d = new Date(toInt(input));
|
11670 | });
|
11671 |
|
11672 | hooks.version = '2.24.0';
|
11673 | setHookCallback(createLocal);
|
11674 | hooks.fn = proto;
|
11675 | hooks.min = min;
|
11676 | hooks.max = max;
|
11677 | hooks.now = now;
|
11678 | hooks.utc = createUTC;
|
11679 | hooks.unix = createUnix;
|
11680 | hooks.months = listMonths;
|
11681 | hooks.isDate = isDate;
|
11682 | hooks.locale = getSetGlobalLocale;
|
11683 | hooks.invalid = createInvalid;
|
11684 | hooks.duration = createDuration;
|
11685 | hooks.isMoment = isMoment;
|
11686 | hooks.weekdays = listWeekdays;
|
11687 | hooks.parseZone = createInZone;
|
11688 | hooks.localeData = getLocale;
|
11689 | hooks.isDuration = isDuration;
|
11690 | hooks.monthsShort = listMonthsShort;
|
11691 | hooks.weekdaysMin = listWeekdaysMin;
|
11692 | hooks.defineLocale = defineLocale;
|
11693 | hooks.updateLocale = updateLocale;
|
11694 | hooks.locales = listLocales;
|
11695 | hooks.weekdaysShort = listWeekdaysShort;
|
11696 | hooks.normalizeUnits = normalizeUnits;
|
11697 | hooks.relativeTimeRounding = getSetRelativeTimeRounding;
|
11698 | hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
|
11699 | hooks.calendarFormat = getCalendarFormat;
|
11700 | hooks.prototype = proto;
|
11701 |
|
11702 | hooks.HTML5_FMT = {
|
11703 | DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm',
|
11704 |
|
11705 | DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss',
|
11706 |
|
11707 | DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS',
|
11708 |
|
11709 | DATE: 'YYYY-MM-DD',
|
11710 |
|
11711 | TIME: 'HH:mm',
|
11712 |
|
11713 | TIME_SECONDS: 'HH:mm:ss',
|
11714 |
|
11715 | TIME_MS: 'HH:mm:ss.SSS',
|
11716 |
|
11717 | WEEK: 'GGGG-[W]WW',
|
11718 |
|
11719 | MONTH: 'YYYY-MM'
|
11720 |
|
11721 | };
|
11722 | return hooks;
|
11723 | });
|
11724 | });
|
11725 |
|
11726 | var byteToHex$2 = [];
|
11727 | var hexToByte = {};
|
11728 |
|
11729 | for (var i$2 = 0; i$2 < 256; i$2++) {
|
11730 | byteToHex$2[i$2] = (i$2 + 0x100).toString(16).substr(1);
|
11731 | hexToByte[byteToHex$2[i$2]] = i$2;
|
11732 | }
|
11733 |
|
11734 |
|
11735 |
|
11736 |
|
11737 |
|
11738 |
|
11739 |
|
11740 |
|
11741 |
|
11742 |
|
11743 |
|
11744 | function parseUUID(str) {
|
11745 | var buf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
11746 | var offset = arguments.length > 2 ? arguments[2] : undefined;
|
11747 | var i = buf && offset || 0;
|
11748 | var ii = 0;
|
11749 | str.toLowerCase().replace(/[0-9a-f]{2}/g, function (oct) {
|
11750 | if (ii < 16) {
|
11751 |
|
11752 | buf[i + ii++] = hexToByte[oct];
|
11753 | }
|
11754 |
|
11755 | return '';
|
11756 | });
|
11757 |
|
11758 | while (ii < 16) {
|
11759 | buf[i + ii++] = 0;
|
11760 | }
|
11761 |
|
11762 | return buf;
|
11763 | }
|
11764 |
|
11765 |
|
11766 |
|
11767 |
|
11768 |
|
11769 |
|
11770 |
|
11771 |
|
11772 |
|
11773 |
|
11774 | function stringifyUUID$1(buf, offset) {
|
11775 | var i = offset || 0;
|
11776 | var bth = byteToHex$2;
|
11777 | 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++]];
|
11778 | }
|
11779 |
|
11780 |
|
11781 |
|
11782 |
|
11783 |
|
11784 |
|
11785 |
|
11786 | var random$1 = function () {
|
11787 | if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
11788 |
|
11789 |
|
11790 | var _rnds8 = new Uint8Array(16);
|
11791 |
|
11792 | return function whatwgRNG() {
|
11793 | crypto.getRandomValues(_rnds8);
|
11794 | return _rnds8;
|
11795 | };
|
11796 | }
|
11797 |
|
11798 |
|
11799 |
|
11800 |
|
11801 |
|
11802 | var _rnds = new Array(16);
|
11803 |
|
11804 | return function () {
|
11805 | for (var i = 0, r; i < 16; i++) {
|
11806 | if ((i & 0x03) === 0) {
|
11807 | r = Math.random() * 0x100000000;
|
11808 | }
|
11809 |
|
11810 | _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
11811 | }
|
11812 |
|
11813 | return _rnds;
|
11814 | };
|
11815 |
|
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 |
|
11821 |
|
11822 | }();
|
11823 |
|
11824 | var byteToHex$1$1 = [];
|
11825 |
|
11826 | for (var i$1$1 = 0; i$1$1 < 256; i$1$1++) {
|
11827 | byteToHex$1$1[i$1$1] = (i$1$1 + 0x100).toString(16).substr(1);
|
11828 | }
|
11829 |
|
11830 |
|
11831 |
|
11832 |
|
11833 |
|
11834 |
|
11835 | var seedBytes$1 = random$1();
|
11836 |
|
11837 | var defaultNodeId$1 = [seedBytes$1[0] | 0x01, seedBytes$1[1], seedBytes$1[2], seedBytes$1[3], seedBytes$1[4], seedBytes$1[5]];
|
11838 |
|
11839 | var defaultClockseq$1 = (seedBytes$1[6] << 8 | seedBytes$1[7]) & 0x3fff;
|
11840 |
|
11841 | var lastMSecs = 0;
|
11842 | var lastNSecs = 0;
|
11843 |
|
11844 |
|
11845 |
|
11846 |
|
11847 |
|
11848 |
|
11849 |
|
11850 |
|
11851 |
|
11852 |
|
11853 |
|
11854 |
|
11855 |
|
11856 |
|
11857 | function uuid1() {
|
11858 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
11859 | var buf = arguments.length > 1 ? arguments[1] : undefined;
|
11860 | var offset = arguments.length > 2 ? arguments[2] : undefined;
|
11861 | var i = buf && offset || 0;
|
11862 | var b = buf || [];
|
11863 | var clockseq = options.clockseq !== undefined ? options.clockseq : defaultClockseq$1;
|
11864 |
|
11865 |
|
11866 |
|
11867 |
|
11868 | var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
|
11869 |
|
11870 |
|
11871 | var nsecs = options.nsecs !== undefined ? options.nsecs : lastNSecs + 1;
|
11872 |
|
11873 | var dt = msecs - lastMSecs + (nsecs - lastNSecs) / 10000;
|
11874 |
|
11875 | if (dt < 0 && options.clockseq === undefined) {
|
11876 | clockseq = clockseq + 1 & 0x3fff;
|
11877 | }
|
11878 |
|
11879 |
|
11880 |
|
11881 | if ((dt < 0 || msecs > lastMSecs) && options.nsecs === undefined) {
|
11882 | nsecs = 0;
|
11883 | }
|
11884 |
|
11885 |
|
11886 | if (nsecs >= 10000) {
|
11887 | throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
11888 | }
|
11889 |
|
11890 | lastMSecs = msecs;
|
11891 | lastNSecs = nsecs;
|
11892 | defaultClockseq$1 = clockseq;
|
11893 |
|
11894 | msecs += 12219292800000;
|
11895 |
|
11896 | var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
11897 | b[i++] = tl >>> 24 & 0xff;
|
11898 | b[i++] = tl >>> 16 & 0xff;
|
11899 | b[i++] = tl >>> 8 & 0xff;
|
11900 | b[i++] = tl & 0xff;
|
11901 |
|
11902 | var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
|
11903 | b[i++] = tmh >>> 8 & 0xff;
|
11904 | b[i++] = tmh & 0xff;
|
11905 |
|
11906 | b[i++] = tmh >>> 24 & 0xf | 0x10;
|
11907 |
|
11908 | b[i++] = tmh >>> 16 & 0xff;
|
11909 |
|
11910 | b[i++] = clockseq >>> 8 | 0x80;
|
11911 |
|
11912 | b[i++] = clockseq & 0xff;
|
11913 |
|
11914 | var node = options.node || defaultNodeId$1;
|
11915 |
|
11916 | for (var n = 0; n < 6; n++) {
|
11917 | b[i + n] = node[n];
|
11918 | }
|
11919 |
|
11920 | return buf ? buf : stringifyUUID$1(b);
|
11921 | }
|
11922 |
|
11923 |
|
11924 |
|
11925 |
|
11926 |
|
11927 |
|
11928 |
|
11929 |
|
11930 |
|
11931 |
|
11932 |
|
11933 |
|
11934 |
|
11935 |
|
11936 |
|
11937 |
|
11938 | function uuid4$1() {
|
11939 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
11940 | var buf = arguments.length > 1 ? arguments[1] : undefined;
|
11941 | var offset = arguments.length > 2 ? arguments[2] : undefined;
|
11942 |
|
11943 | var i = buf && offset || 0;
|
11944 |
|
11945 | if (typeof options === 'string') {
|
11946 | buf = options === 'binary' ? new Array(16) : undefined;
|
11947 | options = {};
|
11948 | }
|
11949 |
|
11950 | var rnds = options.random || (options.rng || random$1)();
|
11951 |
|
11952 | rnds[6] = rnds[6] & 0x0f | 0x40;
|
11953 | rnds[8] = rnds[8] & 0x3f | 0x80;
|
11954 |
|
11955 | if (buf) {
|
11956 | for (var ii = 0; ii < 16; ii++) {
|
11957 | buf[i + ii] = rnds[ii];
|
11958 | }
|
11959 | }
|
11960 |
|
11961 | return buf || stringifyUUID$1(rnds);
|
11962 | }
|
11963 |
|
11964 |
|
11965 |
|
11966 |
|
11967 |
|
11968 |
|
11969 |
|
11970 | var oldAPI = function oldAPI() {
|
11971 | return uuid4$1.apply(void 0, arguments);
|
11972 | };
|
11973 |
|
11974 | oldAPI.v1 = uuid1;
|
11975 | oldAPI.v4 = uuid4$1;
|
11976 | oldAPI.parse = parseUUID;
|
11977 | oldAPI.unparse = stringifyUUID$1;
|
11978 | var esm = createCommonjsModule$2(function (module, exports) {
|
11979 | function _typeof(obj) {
|
11980 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
11981 | _typeof = function (obj) {
|
11982 | return typeof obj;
|
11983 | };
|
11984 | } else {
|
11985 | _typeof = function (obj) {
|
11986 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
11987 | };
|
11988 | }
|
11989 |
|
11990 | return _typeof(obj);
|
11991 | }
|
11992 |
|
11993 |
|
11994 |
|
11995 | |
11996 |
|
11997 |
|
11998 |
|
11999 |
|
12000 |
|
12001 |
|
12002 | exports.isNumber = function (object) {
|
12003 | return object instanceof Number || typeof object == 'number';
|
12004 | };
|
12005 | |
12006 |
|
12007 |
|
12008 |
|
12009 |
|
12010 |
|
12011 | exports.recursiveDOMDelete = function (DOMobject) {
|
12012 | if (DOMobject) {
|
12013 | while (DOMobject.hasChildNodes() === true) {
|
12014 | exports.recursiveDOMDelete(DOMobject.firstChild);
|
12015 | DOMobject.removeChild(DOMobject.firstChild);
|
12016 | }
|
12017 | }
|
12018 | };
|
12019 | |
12020 |
|
12021 |
|
12022 |
|
12023 |
|
12024 |
|
12025 |
|
12026 | exports.isString = function (object) {
|
12027 | return object instanceof String || typeof object == 'string';
|
12028 | };
|
12029 | |
12030 |
|
12031 |
|
12032 |
|
12033 |
|
12034 |
|
12035 |
|
12036 | exports.isDate = function (object) {
|
12037 | if (object instanceof Date) {
|
12038 | return true;
|
12039 | } else if (exports.isString(object)) {
|
12040 |
|
12041 | var match = ASPDateRegex.exec(object);
|
12042 |
|
12043 | if (match) {
|
12044 | return true;
|
12045 | } else if (!isNaN(Date.parse(object))) {
|
12046 | return true;
|
12047 | }
|
12048 | }
|
12049 |
|
12050 | return false;
|
12051 | };
|
12052 | |
12053 |
|
12054 |
|
12055 |
|
12056 |
|
12057 |
|
12058 | exports.randomUUID = function () {
|
12059 | return oldAPI.v4();
|
12060 | };
|
12061 | |
12062 |
|
12063 |
|
12064 |
|
12065 |
|
12066 |
|
12067 |
|
12068 |
|
12069 |
|
12070 |
|
12071 |
|
12072 |
|
12073 |
|
12074 |
|
12075 | function copyOrDelete(a, b, prop, allowDeletion) {
|
12076 | var doDeletion = false;
|
12077 |
|
12078 | if (allowDeletion === true) {
|
12079 | doDeletion = b[prop] === null && a[prop] !== undefined;
|
12080 | }
|
12081 |
|
12082 | if (doDeletion) {
|
12083 | delete a[prop];
|
12084 | } else {
|
12085 | a[prop] = b[prop];
|
12086 | }
|
12087 | }
|
12088 | |
12089 |
|
12090 |
|
12091 |
|
12092 |
|
12093 |
|
12094 |
|
12095 |
|
12096 |
|
12097 |
|
12098 |
|
12099 |
|
12100 | exports.fillIfDefined = function (a, b) {
|
12101 | var allowDeletion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
12102 |
|
12103 |
|
12104 | for (var prop in a) {
|
12105 | if (b[prop] !== undefined) {
|
12106 | if (b[prop] === null || _typeof(b[prop]) !== 'object') {
|
12107 |
|
12108 | copyOrDelete(a, b, prop, allowDeletion);
|
12109 | } else {
|
12110 | if (_typeof(a[prop]) === 'object') {
|
12111 | exports.fillIfDefined(a[prop], b[prop], allowDeletion);
|
12112 | }
|
12113 | }
|
12114 | }
|
12115 | }
|
12116 | };
|
12117 | |
12118 |
|
12119 |
|
12120 |
|
12121 |
|
12122 |
|
12123 |
|
12124 |
|
12125 |
|
12126 | exports.extend = function (a, b) {
|
12127 |
|
12128 | for (var i = 1; i < arguments.length; i++) {
|
12129 | var other = arguments[i];
|
12130 |
|
12131 | for (var prop in other) {
|
12132 | if (other.hasOwnProperty(prop)) {
|
12133 | a[prop] = other[prop];
|
12134 | }
|
12135 | }
|
12136 | }
|
12137 |
|
12138 | return a;
|
12139 | };
|
12140 | |
12141 |
|
12142 |
|
12143 |
|
12144 |
|
12145 |
|
12146 |
|
12147 |
|
12148 |
|
12149 |
|
12150 | exports.selectiveExtend = function (props, a, b) {
|
12151 |
|
12152 | if (!Array.isArray(props)) {
|
12153 | throw new Error('Array with property names expected as first argument');
|
12154 | }
|
12155 |
|
12156 | for (var i = 2; i < arguments.length; i++) {
|
12157 | var other = arguments[i];
|
12158 |
|
12159 | for (var p = 0; p < props.length; p++) {
|
12160 | var prop = props[p];
|
12161 |
|
12162 | if (other && other.hasOwnProperty(prop)) {
|
12163 | a[prop] = other[prop];
|
12164 | }
|
12165 | }
|
12166 | }
|
12167 |
|
12168 | return a;
|
12169 | };
|
12170 | |
12171 |
|
12172 |
|
12173 |
|
12174 |
|
12175 |
|
12176 |
|
12177 |
|
12178 |
|
12179 |
|
12180 |
|
12181 |
|
12182 |
|
12183 |
|
12184 |
|
12185 |
|
12186 |
|
12187 | exports.selectiveDeepExtend = function (props, a, b) {
|
12188 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
12189 |
|
12190 | if (Array.isArray(b)) {
|
12191 | throw new TypeError('Arrays are not supported by deepExtend');
|
12192 | }
|
12193 |
|
12194 | for (var p = 0; p < props.length; p++) {
|
12195 | var prop = props[p];
|
12196 |
|
12197 | if (b.hasOwnProperty(prop)) {
|
12198 | if (b[prop] && b[prop].constructor === Object) {
|
12199 | if (a[prop] === undefined) {
|
12200 | a[prop] = {};
|
12201 | }
|
12202 |
|
12203 | if (a[prop].constructor === Object) {
|
12204 | exports.deepExtend(a[prop], b[prop], false, allowDeletion);
|
12205 | } else {
|
12206 | copyOrDelete(a, b, prop, allowDeletion);
|
12207 | }
|
12208 | } else if (Array.isArray(b[prop])) {
|
12209 | throw new TypeError('Arrays are not supported by deepExtend');
|
12210 | } else {
|
12211 | copyOrDelete(a, b, prop, allowDeletion);
|
12212 | }
|
12213 | }
|
12214 | }
|
12215 |
|
12216 | return a;
|
12217 | };
|
12218 | |
12219 |
|
12220 |
|
12221 |
|
12222 |
|
12223 |
|
12224 |
|
12225 |
|
12226 |
|
12227 |
|
12228 |
|
12229 |
|
12230 |
|
12231 |
|
12232 |
|
12233 |
|
12234 | exports.selectiveNotDeepExtend = function (propsToExclude, a, b) {
|
12235 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
12236 |
|
12237 |
|
12238 | if (Array.isArray(b)) {
|
12239 | throw new TypeError('Arrays are not supported by deepExtend');
|
12240 | }
|
12241 |
|
12242 | for (var prop in b) {
|
12243 | if (!b.hasOwnProperty(prop)) continue;
|
12244 |
|
12245 | if (propsToExclude.indexOf(prop) !== -1) continue;
|
12246 |
|
12247 | if (b[prop] && b[prop].constructor === Object) {
|
12248 | if (a[prop] === undefined) {
|
12249 | a[prop] = {};
|
12250 | }
|
12251 |
|
12252 | if (a[prop].constructor === Object) {
|
12253 | exports.deepExtend(a[prop], b[prop]);
|
12254 | } else {
|
12255 | copyOrDelete(a, b, prop, allowDeletion);
|
12256 | }
|
12257 | } else if (Array.isArray(b[prop])) {
|
12258 | a[prop] = [];
|
12259 |
|
12260 | for (var i = 0; i < b[prop].length; i++) {
|
12261 | a[prop].push(b[prop][i]);
|
12262 | }
|
12263 | } else {
|
12264 | copyOrDelete(a, b, prop, allowDeletion);
|
12265 | }
|
12266 | }
|
12267 |
|
12268 | return a;
|
12269 | };
|
12270 | |
12271 |
|
12272 |
|
12273 |
|
12274 |
|
12275 |
|
12276 |
|
12277 |
|
12278 |
|
12279 |
|
12280 |
|
12281 |
|
12282 | exports.deepExtend = function (a, b) {
|
12283 | var protoExtend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
12284 | var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
12285 |
|
12286 | for (var prop in b) {
|
12287 | if (b.hasOwnProperty(prop) || protoExtend === true) {
|
12288 | if (b[prop] && b[prop].constructor === Object) {
|
12289 | if (a[prop] === undefined) {
|
12290 | a[prop] = {};
|
12291 | }
|
12292 |
|
12293 | if (a[prop].constructor === Object) {
|
12294 | exports.deepExtend(a[prop], b[prop], protoExtend);
|
12295 | } else {
|
12296 | copyOrDelete(a, b, prop, allowDeletion);
|
12297 | }
|
12298 | } else if (Array.isArray(b[prop])) {
|
12299 | a[prop] = [];
|
12300 |
|
12301 | for (var i = 0; i < b[prop].length; i++) {
|
12302 | a[prop].push(b[prop][i]);
|
12303 | }
|
12304 | } else {
|
12305 | copyOrDelete(a, b, prop, allowDeletion);
|
12306 | }
|
12307 | }
|
12308 | }
|
12309 |
|
12310 | return a;
|
12311 | };
|
12312 | |
12313 |
|
12314 |
|
12315 |
|
12316 |
|
12317 |
|
12318 |
|
12319 |
|
12320 |
|
12321 | exports.equalArray = function (a, b) {
|
12322 | if (a.length != b.length) return false;
|
12323 |
|
12324 | for (var i = 0, len = a.length; i < len; i++) {
|
12325 | if (a[i] != b[i]) return false;
|
12326 | }
|
12327 |
|
12328 | return true;
|
12329 | };
|
12330 | |
12331 |
|
12332 |
|
12333 |
|
12334 |
|
12335 |
|
12336 |
|
12337 |
|
12338 |
|
12339 |
|
12340 |
|
12341 | exports.convert = function (object, type) {
|
12342 | var match;
|
12343 |
|
12344 | if (object === undefined) {
|
12345 | return undefined;
|
12346 | }
|
12347 |
|
12348 | if (object === null) {
|
12349 | return null;
|
12350 | }
|
12351 |
|
12352 | if (!type) {
|
12353 | return object;
|
12354 | }
|
12355 |
|
12356 | if (!(typeof type === 'string') && !(type instanceof String)) {
|
12357 | throw new Error('Type must be a string');
|
12358 | }
|
12359 |
|
12360 |
|
12361 | switch (type) {
|
12362 | case 'boolean':
|
12363 | case 'Boolean':
|
12364 | return Boolean(object);
|
12365 |
|
12366 | case 'number':
|
12367 | case 'Number':
|
12368 | if (exports.isString(object) && !isNaN(Date.parse(object))) {
|
12369 | return moment$1(object).valueOf();
|
12370 | } else {
|
12371 | return Number(object.valueOf());
|
12372 | }
|
12373 |
|
12374 | case 'string':
|
12375 | case 'String':
|
12376 | return String(object);
|
12377 |
|
12378 | case 'Date':
|
12379 | if (exports.isNumber(object)) {
|
12380 | return new Date(object);
|
12381 | }
|
12382 |
|
12383 | if (object instanceof Date) {
|
12384 | return new Date(object.valueOf());
|
12385 | } else if (moment$1.isMoment(object)) {
|
12386 | return new Date(object.valueOf());
|
12387 | }
|
12388 |
|
12389 | if (exports.isString(object)) {
|
12390 | match = ASPDateRegex.exec(object);
|
12391 |
|
12392 | if (match) {
|
12393 |
|
12394 | return new Date(Number(match[1]));
|
12395 | } else {
|
12396 | return moment$1(new Date(object)).toDate();
|
12397 | }
|
12398 | } else {
|
12399 | throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type Date');
|
12400 | }
|
12401 |
|
12402 | case 'Moment':
|
12403 | if (exports.isNumber(object)) {
|
12404 | return moment$1(object);
|
12405 | }
|
12406 |
|
12407 | if (object instanceof Date) {
|
12408 | return moment$1(object.valueOf());
|
12409 | } else if (moment$1.isMoment(object)) {
|
12410 | return moment$1(object);
|
12411 | }
|
12412 |
|
12413 | if (exports.isString(object)) {
|
12414 | match = ASPDateRegex.exec(object);
|
12415 |
|
12416 | if (match) {
|
12417 |
|
12418 | return moment$1(Number(match[1]));
|
12419 | } else {
|
12420 | return moment$1(object);
|
12421 | }
|
12422 | } else {
|
12423 | throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type Date');
|
12424 | }
|
12425 |
|
12426 | case 'ISODate':
|
12427 | if (exports.isNumber(object)) {
|
12428 | return new Date(object);
|
12429 | } else if (object instanceof Date) {
|
12430 | return object.toISOString();
|
12431 | } else if (moment$1.isMoment(object)) {
|
12432 | return object.toDate().toISOString();
|
12433 | } else if (exports.isString(object)) {
|
12434 | match = ASPDateRegex.exec(object);
|
12435 |
|
12436 | if (match) {
|
12437 |
|
12438 | return new Date(Number(match[1])).toISOString();
|
12439 | } else {
|
12440 | return moment$1(object).format();
|
12441 | }
|
12442 | } else {
|
12443 | throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type ISODate');
|
12444 | }
|
12445 |
|
12446 | case 'ASPDate':
|
12447 | if (exports.isNumber(object)) {
|
12448 | return '/Date(' + object + ')/';
|
12449 | } else if (object instanceof Date) {
|
12450 | return '/Date(' + object.valueOf() + ')/';
|
12451 | } else if (exports.isString(object)) {
|
12452 | match = ASPDateRegex.exec(object);
|
12453 | var value;
|
12454 |
|
12455 | if (match) {
|
12456 |
|
12457 | value = new Date(Number(match[1])).valueOf();
|
12458 | } else {
|
12459 | value = new Date(object).valueOf();
|
12460 | }
|
12461 |
|
12462 | return '/Date(' + value + ')/';
|
12463 | } else {
|
12464 | throw new Error('Cannot convert object of type ' + exports.getType(object) + ' to type ASPDate');
|
12465 | }
|
12466 |
|
12467 | default:
|
12468 | throw new Error('Unknown type "' + type + '"');
|
12469 | }
|
12470 | };
|
12471 |
|
12472 |
|
12473 |
|
12474 |
|
12475 | var ASPDateRegex = /^\/?Date\((\-?\d+)/i;
|
12476 | |
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 |
|
12482 | exports.getType = function (object) {
|
12483 | var type = _typeof(object);
|
12484 |
|
12485 | if (type == 'object') {
|
12486 | if (object === null) {
|
12487 | return 'null';
|
12488 | }
|
12489 |
|
12490 | if (object instanceof Boolean) {
|
12491 | return 'Boolean';
|
12492 | }
|
12493 |
|
12494 | if (object instanceof Number) {
|
12495 | return 'Number';
|
12496 | }
|
12497 |
|
12498 | if (object instanceof String) {
|
12499 | return 'String';
|
12500 | }
|
12501 |
|
12502 | if (Array.isArray(object)) {
|
12503 | return 'Array';
|
12504 | }
|
12505 |
|
12506 | if (object instanceof Date) {
|
12507 | return 'Date';
|
12508 | }
|
12509 |
|
12510 | return 'Object';
|
12511 | } else if (type == 'number') {
|
12512 | return 'Number';
|
12513 | } else if (type == 'boolean') {
|
12514 | return 'Boolean';
|
12515 | } else if (type == 'string') {
|
12516 | return 'String';
|
12517 | } else if (type === undefined) {
|
12518 | return 'undefined';
|
12519 | }
|
12520 |
|
12521 | return type;
|
12522 | };
|
12523 | |
12524 |
|
12525 |
|
12526 |
|
12527 |
|
12528 |
|
12529 |
|
12530 |
|
12531 |
|
12532 | exports.copyAndExtendArray = function (arr, newValue) {
|
12533 | var newArr = [];
|
12534 |
|
12535 | for (var i = 0; i < arr.length; i++) {
|
12536 | newArr.push(arr[i]);
|
12537 | }
|
12538 |
|
12539 | newArr.push(newValue);
|
12540 | return newArr;
|
12541 | };
|
12542 | |
12543 |
|
12544 |
|
12545 |
|
12546 |
|
12547 |
|
12548 |
|
12549 |
|
12550 | exports.copyArray = function (arr) {
|
12551 | var newArr = [];
|
12552 |
|
12553 | for (var i = 0; i < arr.length; i++) {
|
12554 | newArr.push(arr[i]);
|
12555 | }
|
12556 |
|
12557 | return newArr;
|
12558 | };
|
12559 | |
12560 |
|
12561 |
|
12562 |
|
12563 |
|
12564 |
|
12565 |
|
12566 |
|
12567 | exports.getAbsoluteLeft = function (elem) {
|
12568 | return elem.getBoundingClientRect().left;
|
12569 | };
|
12570 |
|
12571 | exports.getAbsoluteRight = function (elem) {
|
12572 | return elem.getBoundingClientRect().right;
|
12573 | };
|
12574 | |
12575 |
|
12576 |
|
12577 |
|
12578 |
|
12579 |
|
12580 |
|
12581 |
|
12582 | exports.getAbsoluteTop = function (elem) {
|
12583 | return elem.getBoundingClientRect().top;
|
12584 | };
|
12585 | |
12586 |
|
12587 |
|
12588 |
|
12589 |
|
12590 |
|
12591 |
|
12592 | exports.addClassName = function (elem, classNames) {
|
12593 | var classes = elem.className.split(' ');
|
12594 | var newClasses = classNames.split(' ');
|
12595 | classes = classes.concat(newClasses.filter(function (className) {
|
12596 | return classes.indexOf(className) < 0;
|
12597 | }));
|
12598 | elem.className = classes.join(' ');
|
12599 | };
|
12600 | |
12601 |
|
12602 |
|
12603 |
|
12604 |
|
12605 |
|
12606 |
|
12607 | exports.removeClassName = function (elem, classNames) {
|
12608 | var classes = elem.className.split(' ');
|
12609 | var oldClasses = classNames.split(' ');
|
12610 | classes = classes.filter(function (className) {
|
12611 | return oldClasses.indexOf(className) < 0;
|
12612 | });
|
12613 | elem.className = classes.join(' ');
|
12614 | };
|
12615 | |
12616 |
|
12617 |
|
12618 |
|
12619 |
|
12620 |
|
12621 |
|
12622 |
|
12623 |
|
12624 |
|
12625 |
|
12626 | exports.forEach = function (object, callback) {
|
12627 | var i, len;
|
12628 |
|
12629 | if (Array.isArray(object)) {
|
12630 |
|
12631 | for (i = 0, len = object.length; i < len; i++) {
|
12632 | callback(object[i], i, object);
|
12633 | }
|
12634 | } else {
|
12635 |
|
12636 | for (i in object) {
|
12637 | if (object.hasOwnProperty(i)) {
|
12638 | callback(object[i], i, object);
|
12639 | }
|
12640 | }
|
12641 | }
|
12642 | };
|
12643 | |
12644 |
|
12645 |
|
12646 |
|
12647 |
|
12648 |
|
12649 |
|
12650 |
|
12651 | exports.toArray = function (object) {
|
12652 | var array = [];
|
12653 |
|
12654 | for (var prop in object) {
|
12655 | if (object.hasOwnProperty(prop)) array.push(object[prop]);
|
12656 | }
|
12657 |
|
12658 | return array;
|
12659 | };
|
12660 | |
12661 |
|
12662 |
|
12663 |
|
12664 |
|
12665 |
|
12666 |
|
12667 |
|
12668 |
|
12669 | exports.updateProperty = function (object, key, value) {
|
12670 | if (object[key] !== value) {
|
12671 | object[key] = value;
|
12672 | return true;
|
12673 | } else {
|
12674 | return false;
|
12675 | }
|
12676 | };
|
12677 | |
12678 |
|
12679 |
|
12680 |
|
12681 |
|
12682 |
|
12683 |
|
12684 | exports.throttle = function (fn) {
|
12685 | var scheduled = false;
|
12686 | return function throttled() {
|
12687 | if (!scheduled) {
|
12688 | scheduled = true;
|
12689 | requestAnimationFrame(function () {
|
12690 | scheduled = false;
|
12691 | fn();
|
12692 | });
|
12693 | }
|
12694 | };
|
12695 | };
|
12696 | |
12697 |
|
12698 |
|
12699 |
|
12700 |
|
12701 |
|
12702 |
|
12703 |
|
12704 |
|
12705 |
|
12706 | exports.addEventListener = function (element, action, listener, useCapture) {
|
12707 | if (element.addEventListener) {
|
12708 | if (useCapture === undefined) useCapture = false;
|
12709 |
|
12710 | if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
|
12711 | action = "DOMMouseScroll";
|
12712 | }
|
12713 |
|
12714 | element.addEventListener(action, listener, useCapture);
|
12715 | } else {
|
12716 | element.attachEvent("on" + action, listener);
|
12717 | }
|
12718 | };
|
12719 | |
12720 |
|
12721 |
|
12722 |
|
12723 |
|
12724 |
|
12725 |
|
12726 |
|
12727 |
|
12728 | exports.removeEventListener = function (element, action, listener, useCapture) {
|
12729 | if (element.removeEventListener) {
|
12730 |
|
12731 | if (useCapture === undefined) useCapture = false;
|
12732 |
|
12733 | if (action === "mousewheel" && navigator.userAgent.indexOf("Firefox") >= 0) {
|
12734 | action = "DOMMouseScroll";
|
12735 | }
|
12736 |
|
12737 | element.removeEventListener(action, listener, useCapture);
|
12738 | } else {
|
12739 |
|
12740 | element.detachEvent("on" + action, listener);
|
12741 | }
|
12742 | };
|
12743 | |
12744 |
|
12745 |
|
12746 |
|
12747 |
|
12748 |
|
12749 | exports.preventDefault = function (event) {
|
12750 | if (!event) event = window.event;
|
12751 |
|
12752 | if (event.preventDefault) {
|
12753 | event.preventDefault();
|
12754 | } else {
|
12755 | event.returnValue = false;
|
12756 | }
|
12757 | };
|
12758 | |
12759 |
|
12760 |
|
12761 |
|
12762 |
|
12763 |
|
12764 |
|
12765 | exports.getTarget = function (event) {
|
12766 |
|
12767 | if (!event) {
|
12768 | event = window.event;
|
12769 | }
|
12770 |
|
12771 | var target;
|
12772 |
|
12773 | if (event.target) {
|
12774 | target = event.target;
|
12775 | } else if (event.srcElement) {
|
12776 | target = event.srcElement;
|
12777 | }
|
12778 |
|
12779 | if (target.nodeType != undefined && target.nodeType == 3) {
|
12780 |
|
12781 | target = target.parentNode;
|
12782 | }
|
12783 |
|
12784 | return target;
|
12785 | };
|
12786 | |
12787 |
|
12788 |
|
12789 |
|
12790 |
|
12791 |
|
12792 |
|
12793 |
|
12794 | exports.hasParent = function (element, parent) {
|
12795 | var e = element;
|
12796 |
|
12797 | while (e) {
|
12798 | if (e === parent) {
|
12799 | return true;
|
12800 | }
|
12801 |
|
12802 | e = e.parentNode;
|
12803 | }
|
12804 |
|
12805 | return false;
|
12806 | };
|
12807 |
|
12808 | exports.option = {};
|
12809 | |
12810 |
|
12811 |
|
12812 |
|
12813 |
|
12814 |
|
12815 |
|
12816 | exports.option.asBoolean = function (value, defaultValue) {
|
12817 | if (typeof value == 'function') {
|
12818 | value = value();
|
12819 | }
|
12820 |
|
12821 | if (value != null) {
|
12822 | return value != false;
|
12823 | }
|
12824 |
|
12825 | return defaultValue || null;
|
12826 | };
|
12827 | |
12828 |
|
12829 |
|
12830 |
|
12831 |
|
12832 |
|
12833 |
|
12834 |
|
12835 | exports.option.asNumber = function (value, defaultValue) {
|
12836 | if (typeof value == 'function') {
|
12837 | value = value();
|
12838 | }
|
12839 |
|
12840 | if (value != null) {
|
12841 | return Number(value) || defaultValue || null;
|
12842 | }
|
12843 |
|
12844 | return defaultValue || null;
|
12845 | };
|
12846 | |
12847 |
|
12848 |
|
12849 |
|
12850 |
|
12851 |
|
12852 |
|
12853 |
|
12854 | exports.option.asString = function (value, defaultValue) {
|
12855 | if (typeof value == 'function') {
|
12856 | value = value();
|
12857 | }
|
12858 |
|
12859 | if (value != null) {
|
12860 | return String(value);
|
12861 | }
|
12862 |
|
12863 | return defaultValue || null;
|
12864 | };
|
12865 | |
12866 |
|
12867 |
|
12868 |
|
12869 |
|
12870 |
|
12871 |
|
12872 |
|
12873 | exports.option.asSize = function (value, defaultValue) {
|
12874 | if (typeof value == 'function') {
|
12875 | value = value();
|
12876 | }
|
12877 |
|
12878 | if (exports.isString(value)) {
|
12879 | return value;
|
12880 | } else if (exports.isNumber(value)) {
|
12881 | return value + 'px';
|
12882 | } else {
|
12883 | return defaultValue || null;
|
12884 | }
|
12885 | };
|
12886 | |
12887 |
|
12888 |
|
12889 |
|
12890 |
|
12891 |
|
12892 |
|
12893 |
|
12894 | exports.option.asElement = function (value, defaultValue) {
|
12895 | if (typeof value == 'function') {
|
12896 | value = value();
|
12897 | }
|
12898 |
|
12899 | return value || defaultValue || null;
|
12900 | };
|
12901 | |
12902 |
|
12903 |
|
12904 |
|
12905 |
|
12906 |
|
12907 |
|
12908 |
|
12909 | exports.hexToRGB = function (hex) {
|
12910 |
|
12911 | var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
12912 | hex = hex.replace(shorthandRegex, function (m, r, g, b) {
|
12913 | return r + r + g + g + b + b;
|
12914 | });
|
12915 | var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
12916 | return result ? {
|
12917 | r: parseInt(result[1], 16),
|
12918 | g: parseInt(result[2], 16),
|
12919 | b: parseInt(result[3], 16)
|
12920 | } : null;
|
12921 | };
|
12922 | |
12923 |
|
12924 |
|
12925 |
|
12926 |
|
12927 |
|
12928 |
|
12929 |
|
12930 | exports.overrideOpacity = function (color, opacity) {
|
12931 | var rgb;
|
12932 |
|
12933 | if (color.indexOf("rgba") != -1) {
|
12934 | return color;
|
12935 | } else if (color.indexOf("rgb") != -1) {
|
12936 | rgb = color.substr(color.indexOf("(") + 1).replace(")", "").split(",");
|
12937 | return "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + opacity + ")";
|
12938 | } else {
|
12939 | rgb = exports.hexToRGB(color);
|
12940 |
|
12941 | if (rgb == null) {
|
12942 | return color;
|
12943 | } else {
|
12944 | return "rgba(" + rgb.r + "," + rgb.g + "," + rgb.b + "," + opacity + ")";
|
12945 | }
|
12946 | }
|
12947 | };
|
12948 | |
12949 |
|
12950 |
|
12951 |
|
12952 |
|
12953 |
|
12954 |
|
12955 |
|
12956 |
|
12957 |
|
12958 | exports.RGBToHex = function (red, green, blue) {
|
12959 | return "#" + ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1);
|
12960 | };
|
12961 | |
12962 |
|
12963 |
|
12964 |
|
12965 |
|
12966 |
|
12967 |
|
12968 |
|
12969 | exports.parseColor = function (color) {
|
12970 | var c;
|
12971 |
|
12972 | if (exports.isString(color) === true) {
|
12973 | if (exports.isValidRGB(color) === true) {
|
12974 | var rgb = color.substr(4).substr(0, color.length - 5).split(',').map(function (value) {
|
12975 | return parseInt(value);
|
12976 | });
|
12977 | color = exports.RGBToHex(rgb[0], rgb[1], rgb[2]);
|
12978 | }
|
12979 |
|
12980 | if (exports.isValidHex(color) === true) {
|
12981 | var hsv = exports.hexToHSV(color);
|
12982 | var lighterColorHSV = {
|
12983 | h: hsv.h,
|
12984 | s: hsv.s * 0.8,
|
12985 | v: Math.min(1, hsv.v * 1.02)
|
12986 | };
|
12987 | var darkerColorHSV = {
|
12988 | h: hsv.h,
|
12989 | s: Math.min(1, hsv.s * 1.25),
|
12990 | v: hsv.v * 0.8
|
12991 | };
|
12992 | var darkerColorHex = exports.HSVToHex(darkerColorHSV.h, darkerColorHSV.s, darkerColorHSV.v);
|
12993 | var lighterColorHex = exports.HSVToHex(lighterColorHSV.h, lighterColorHSV.s, lighterColorHSV.v);
|
12994 | c = {
|
12995 | background: color,
|
12996 | border: darkerColorHex,
|
12997 | highlight: {
|
12998 | background: lighterColorHex,
|
12999 | border: darkerColorHex
|
13000 | },
|
13001 | hover: {
|
13002 | background: lighterColorHex,
|
13003 | border: darkerColorHex
|
13004 | }
|
13005 | };
|
13006 | } else {
|
13007 | c = {
|
13008 | background: color,
|
13009 | border: color,
|
13010 | highlight: {
|
13011 | background: color,
|
13012 | border: color
|
13013 | },
|
13014 | hover: {
|
13015 | background: color,
|
13016 | border: color
|
13017 | }
|
13018 | };
|
13019 | }
|
13020 | } else {
|
13021 | c = {};
|
13022 | c.background = color.background || undefined;
|
13023 | c.border = color.border || undefined;
|
13024 |
|
13025 | if (exports.isString(color.highlight)) {
|
13026 | c.highlight = {
|
13027 | border: color.highlight,
|
13028 | background: color.highlight
|
13029 | };
|
13030 | } else {
|
13031 | c.highlight = {};
|
13032 | c.highlight.background = color.highlight && color.highlight.background || undefined;
|
13033 | c.highlight.border = color.highlight && color.highlight.border || undefined;
|
13034 | }
|
13035 |
|
13036 | if (exports.isString(color.hover)) {
|
13037 | c.hover = {
|
13038 | border: color.hover,
|
13039 | background: color.hover
|
13040 | };
|
13041 | } else {
|
13042 | c.hover = {};
|
13043 | c.hover.background = color.hover && color.hover.background || undefined;
|
13044 | c.hover.border = color.hover && color.hover.border || undefined;
|
13045 | }
|
13046 | }
|
13047 |
|
13048 | return c;
|
13049 | };
|
13050 | |
13051 |
|
13052 |
|
13053 |
|
13054 |
|
13055 |
|
13056 |
|
13057 |
|
13058 |
|
13059 |
|
13060 |
|
13061 | exports.RGBToHSV = function (red, green, blue) {
|
13062 | red = red / 255;
|
13063 | green = green / 255;
|
13064 | blue = blue / 255;
|
13065 | var minRGB = Math.min(red, Math.min(green, blue));
|
13066 | var maxRGB = Math.max(red, Math.max(green, blue));
|
13067 |
|
13068 | if (minRGB == maxRGB) {
|
13069 | return {
|
13070 | h: 0,
|
13071 | s: 0,
|
13072 | v: minRGB
|
13073 | };
|
13074 | }
|
13075 |
|
13076 |
|
13077 | var d = red == minRGB ? green - blue : blue == minRGB ? red - green : blue - red;
|
13078 | var h = red == minRGB ? 3 : blue == minRGB ? 1 : 5;
|
13079 | var hue = 60 * (h - d / (maxRGB - minRGB)) / 360;
|
13080 | var saturation = (maxRGB - minRGB) / maxRGB;
|
13081 | var value = maxRGB;
|
13082 | return {
|
13083 | h: hue,
|
13084 | s: saturation,
|
13085 | v: value
|
13086 | };
|
13087 | };
|
13088 |
|
13089 | var cssUtil = {
|
13090 |
|
13091 | split: function split(cssText) {
|
13092 | var styles = {};
|
13093 | cssText.split(';').forEach(function (style) {
|
13094 | if (style.trim() != '') {
|
13095 | var parts = style.split(':');
|
13096 | var key = parts[0].trim();
|
13097 | var value = parts[1].trim();
|
13098 | styles[key] = value;
|
13099 | }
|
13100 | });
|
13101 | return styles;
|
13102 | },
|
13103 |
|
13104 | join: function join(styles) {
|
13105 | return Object.keys(styles).map(function (key) {
|
13106 | return key + ': ' + styles[key];
|
13107 | }).join('; ');
|
13108 | }
|
13109 | };
|
13110 | |
13111 |
|
13112 |
|
13113 |
|
13114 |
|
13115 |
|
13116 | exports.addCssText = function (element, cssText) {
|
13117 | var currentStyles = cssUtil.split(element.style.cssText);
|
13118 | var newStyles = cssUtil.split(cssText);
|
13119 | var styles = exports.extend(currentStyles, newStyles);
|
13120 | element.style.cssText = cssUtil.join(styles);
|
13121 | };
|
13122 | |
13123 |
|
13124 |
|
13125 |
|
13126 |
|
13127 |
|
13128 |
|
13129 | exports.removeCssText = function (element, cssText) {
|
13130 | var styles = cssUtil.split(element.style.cssText);
|
13131 | var removeStyles = cssUtil.split(cssText);
|
13132 |
|
13133 | for (var key in removeStyles) {
|
13134 | if (removeStyles.hasOwnProperty(key)) {
|
13135 | delete styles[key];
|
13136 | }
|
13137 | }
|
13138 |
|
13139 | element.style.cssText = cssUtil.join(styles);
|
13140 | };
|
13141 | |
13142 |
|
13143 |
|
13144 |
|
13145 |
|
13146 |
|
13147 |
|
13148 |
|
13149 |
|
13150 |
|
13151 | exports.HSVToRGB = function (h, s, v) {
|
13152 | var r, g, b;
|
13153 | var i = Math.floor(h * 6);
|
13154 | var f = h * 6 - i;
|
13155 | var p = v * (1 - s);
|
13156 | var q = v * (1 - f * s);
|
13157 | var t = v * (1 - (1 - f) * s);
|
13158 |
|
13159 | switch (i % 6) {
|
13160 | case 0:
|
13161 | r = v, g = t, b = p;
|
13162 | break;
|
13163 |
|
13164 | case 1:
|
13165 | r = q, g = v, b = p;
|
13166 | break;
|
13167 |
|
13168 | case 2:
|
13169 | r = p, g = v, b = t;
|
13170 | break;
|
13171 |
|
13172 | case 3:
|
13173 | r = p, g = q, b = v;
|
13174 | break;
|
13175 |
|
13176 | case 4:
|
13177 | r = t, g = p, b = v;
|
13178 | break;
|
13179 |
|
13180 | case 5:
|
13181 | r = v, g = p, b = q;
|
13182 | break;
|
13183 | }
|
13184 |
|
13185 | return {
|
13186 | r: Math.floor(r * 255),
|
13187 | g: Math.floor(g * 255),
|
13188 | b: Math.floor(b * 255)
|
13189 | };
|
13190 | };
|
13191 |
|
13192 | exports.HSVToHex = function (h, s, v) {
|
13193 | var rgb = exports.HSVToRGB(h, s, v);
|
13194 | return exports.RGBToHex(rgb.r, rgb.g, rgb.b);
|
13195 | };
|
13196 |
|
13197 | exports.hexToHSV = function (hex) {
|
13198 | var rgb = exports.hexToRGB(hex);
|
13199 | return exports.RGBToHSV(rgb.r, rgb.g, rgb.b);
|
13200 | };
|
13201 |
|
13202 | exports.isValidHex = function (hex) {
|
13203 | var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
|
13204 | return isOk;
|
13205 | };
|
13206 |
|
13207 | exports.isValidRGB = function (rgb) {
|
13208 | rgb = rgb.replace(" ", "");
|
13209 | var isOk = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(rgb);
|
13210 | return isOk;
|
13211 | };
|
13212 |
|
13213 | exports.isValidRGBA = function (rgba) {
|
13214 | rgba = rgba.replace(" ", "");
|
13215 | var isOk = /rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i.test(rgba);
|
13216 | return isOk;
|
13217 | };
|
13218 | |
13219 |
|
13220 |
|
13221 |
|
13222 |
|
13223 |
|
13224 |
|
13225 |
|
13226 |
|
13227 |
|
13228 | exports.selectiveBridgeObject = function (fields, referenceObject) {
|
13229 | if (referenceObject !== null && _typeof(referenceObject) === "object") {
|
13230 |
|
13231 | var objectTo = Object.create(referenceObject);
|
13232 |
|
13233 | for (var i = 0; i < fields.length; i++) {
|
13234 | if (referenceObject.hasOwnProperty(fields[i])) {
|
13235 | if (_typeof(referenceObject[fields[i]]) == "object") {
|
13236 | objectTo[fields[i]] = exports.bridgeObject(referenceObject[fields[i]]);
|
13237 | }
|
13238 | }
|
13239 | }
|
13240 |
|
13241 | return objectTo;
|
13242 | } else {
|
13243 | return null;
|
13244 | }
|
13245 | };
|
13246 | |
13247 |
|
13248 |
|
13249 |
|
13250 |
|
13251 |
|
13252 |
|
13253 |
|
13254 |
|
13255 | exports.bridgeObject = function (referenceObject) {
|
13256 | if (referenceObject !== null && _typeof(referenceObject) === "object") {
|
13257 |
|
13258 | var objectTo = Object.create(referenceObject);
|
13259 |
|
13260 | if (referenceObject instanceof Element) {
|
13261 |
|
13262 | objectTo = referenceObject;
|
13263 | } else {
|
13264 | objectTo = Object.create(referenceObject);
|
13265 |
|
13266 | for (var i in referenceObject) {
|
13267 | if (referenceObject.hasOwnProperty(i)) {
|
13268 | if (_typeof(referenceObject[i]) == "object") {
|
13269 | objectTo[i] = exports.bridgeObject(referenceObject[i]);
|
13270 | }
|
13271 | }
|
13272 | }
|
13273 | }
|
13274 |
|
13275 | return objectTo;
|
13276 | } else {
|
13277 | return null;
|
13278 | }
|
13279 | };
|
13280 | |
13281 |
|
13282 |
|
13283 |
|
13284 |
|
13285 |
|
13286 |
|
13287 |
|
13288 |
|
13289 | exports.insertSort = function (a, compare) {
|
13290 | for (var i = 0; i < a.length; i++) {
|
13291 | var k = a[i];
|
13292 |
|
13293 | for (var j = i; j > 0 && compare(k, a[j - 1]) < 0; j--) {
|
13294 | a[j] = a[j - 1];
|
13295 | }
|
13296 |
|
13297 | a[j] = k;
|
13298 | }
|
13299 |
|
13300 | return a;
|
13301 | };
|
13302 | |
13303 |
|
13304 |
|
13305 |
|
13306 |
|
13307 |
|
13308 |
|
13309 |
|
13310 |
|
13311 |
|
13312 |
|
13313 |
|
13314 |
|
13315 |
|
13316 |
|
13317 |
|
13318 | exports.mergeOptions = function (mergeTarget, options, option) {
|
13319 | var globalOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
13320 |
|
13321 | var isPresent = function isPresent(obj) {
|
13322 | return obj !== null && obj !== undefined;
|
13323 | };
|
13324 |
|
13325 | var isObject = function isObject(obj) {
|
13326 | return obj !== null && _typeof(obj) === 'object';
|
13327 | };
|
13328 |
|
13329 |
|
13330 | var isEmpty = function isEmpty(obj) {
|
13331 | for (var x in obj) {
|
13332 | if (obj.hasOwnProperty(x)) return false;
|
13333 | }
|
13334 |
|
13335 | return true;
|
13336 | };
|
13337 |
|
13338 |
|
13339 | if (!isObject(mergeTarget)) {
|
13340 | throw new Error('Parameter mergeTarget must be an object');
|
13341 | }
|
13342 |
|
13343 | if (!isObject(options)) {
|
13344 | throw new Error('Parameter options must be an object');
|
13345 | }
|
13346 |
|
13347 | if (!isPresent(option)) {
|
13348 | throw new Error('Parameter option must have a value');
|
13349 | }
|
13350 |
|
13351 | if (!isObject(globalOptions)) {
|
13352 | throw new Error('Parameter globalOptions must be an object');
|
13353 | }
|
13354 |
|
13355 |
|
13356 |
|
13357 |
|
13358 |
|
13359 | var doMerge = function doMerge(target, options, option) {
|
13360 | if (!isObject(target[option])) {
|
13361 | target[option] = {};
|
13362 | }
|
13363 |
|
13364 | var src = options[option];
|
13365 | var dst = target[option];
|
13366 |
|
13367 | for (var prop in src) {
|
13368 | if (src.hasOwnProperty(prop)) {
|
13369 | dst[prop] = src[prop];
|
13370 | }
|
13371 | }
|
13372 | };
|
13373 |
|
13374 |
|
13375 | var srcOption = options[option];
|
13376 | var globalPassed = isObject(globalOptions) && !isEmpty(globalOptions);
|
13377 | var globalOption = globalPassed ? globalOptions[option] : undefined;
|
13378 | var globalEnabled = globalOption ? globalOption.enabled : undefined;
|
13379 |
|
13380 |
|
13381 |
|
13382 | if (srcOption === undefined) {
|
13383 | return;
|
13384 | }
|
13385 |
|
13386 | if (typeof srcOption === 'boolean') {
|
13387 | if (!isObject(mergeTarget[option])) {
|
13388 | mergeTarget[option] = {};
|
13389 | }
|
13390 |
|
13391 | mergeTarget[option].enabled = srcOption;
|
13392 | return;
|
13393 | }
|
13394 |
|
13395 | if (srcOption === null && !isObject(mergeTarget[option])) {
|
13396 |
|
13397 | if (isPresent(globalOption)) {
|
13398 | mergeTarget[option] = Object.create(globalOption);
|
13399 | } else {
|
13400 | return;
|
13401 | }
|
13402 | }
|
13403 |
|
13404 | if (!isObject(srcOption)) {
|
13405 | return;
|
13406 | }
|
13407 |
|
13408 |
|
13409 |
|
13410 |
|
13411 |
|
13412 | var enabled = true;
|
13413 |
|
13414 | if (srcOption.enabled !== undefined) {
|
13415 | enabled = srcOption.enabled;
|
13416 | } else {
|
13417 |
|
13418 | if (globalEnabled !== undefined) {
|
13419 | enabled = globalOption.enabled;
|
13420 | }
|
13421 | }
|
13422 |
|
13423 | doMerge(mergeTarget, options, option);
|
13424 | mergeTarget[option].enabled = enabled;
|
13425 | };
|
13426 | |
13427 |
|
13428 |
|
13429 |
|
13430 |
|
13431 |
|
13432 |
|
13433 |
|
13434 |
|
13435 |
|
13436 |
|
13437 |
|
13438 |
|
13439 | exports.binarySearchCustom = function (orderedItems, comparator, field, field2) {
|
13440 | var maxIterations = 10000;
|
13441 | var iteration = 0;
|
13442 | var low = 0;
|
13443 | var high = orderedItems.length - 1;
|
13444 |
|
13445 | while (low <= high && iteration < maxIterations) {
|
13446 | var middle = Math.floor((low + high) / 2);
|
13447 | var item = orderedItems[middle];
|
13448 | var value = field2 === undefined ? item[field] : item[field][field2];
|
13449 | var searchResult = comparator(value);
|
13450 |
|
13451 | if (searchResult == 0) {
|
13452 |
|
13453 | return middle;
|
13454 | } else if (searchResult == -1) {
|
13455 |
|
13456 | low = middle + 1;
|
13457 | } else {
|
13458 |
|
13459 | high = middle - 1;
|
13460 | }
|
13461 |
|
13462 | iteration++;
|
13463 | }
|
13464 |
|
13465 | return -1;
|
13466 | };
|
13467 | |
13468 |
|
13469 |
|
13470 |
|
13471 |
|
13472 |
|
13473 |
|
13474 |
|
13475 |
|
13476 |
|
13477 |
|
13478 |
|
13479 |
|
13480 |
|
13481 |
|
13482 | exports.binarySearchValue = function (orderedItems, target, field, sidePreference, comparator) {
|
13483 | var maxIterations = 10000;
|
13484 | var iteration = 0;
|
13485 | var low = 0;
|
13486 | var high = orderedItems.length - 1;
|
13487 | var prevValue, value, nextValue, middle;
|
13488 | comparator = comparator != undefined ? comparator : function (a, b) {
|
13489 | return a == b ? 0 : a < b ? -1 : 1;
|
13490 | };
|
13491 |
|
13492 | while (low <= high && iteration < maxIterations) {
|
13493 |
|
13494 | middle = Math.floor(0.5 * (high + low));
|
13495 | prevValue = orderedItems[Math.max(0, middle - 1)][field];
|
13496 | value = orderedItems[middle][field];
|
13497 | nextValue = orderedItems[Math.min(orderedItems.length - 1, middle + 1)][field];
|
13498 |
|
13499 | if (comparator(value, target) == 0) {
|
13500 |
|
13501 | return middle;
|
13502 | } else if (comparator(prevValue, target) < 0 && comparator(value, target) > 0) {
|
13503 |
|
13504 | return sidePreference == 'before' ? Math.max(0, middle - 1) : middle;
|
13505 | } else if (comparator(value, target) < 0 && comparator(nextValue, target) > 0) {
|
13506 |
|
13507 | return sidePreference == 'before' ? middle : Math.min(orderedItems.length - 1, middle + 1);
|
13508 | } else {
|
13509 |
|
13510 | if (comparator(value, target) < 0) {
|
13511 |
|
13512 | low = middle + 1;
|
13513 | } else {
|
13514 |
|
13515 | high = middle - 1;
|
13516 | }
|
13517 | }
|
13518 |
|
13519 | iteration++;
|
13520 | }
|
13521 |
|
13522 |
|
13523 | return -1;
|
13524 | };
|
13525 | |
13526 |
|
13527 |
|
13528 |
|
13529 |
|
13530 |
|
13531 |
|
13532 | exports.easingFunctions = {
|
13533 |
|
13534 | linear: function linear(t) {
|
13535 | return t;
|
13536 | },
|
13537 |
|
13538 | easeInQuad: function easeInQuad(t) {
|
13539 | return t * t;
|
13540 | },
|
13541 |
|
13542 | easeOutQuad: function easeOutQuad(t) {
|
13543 | return t * (2 - t);
|
13544 | },
|
13545 |
|
13546 | easeInOutQuad: function easeInOutQuad(t) {
|
13547 | return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
13548 | },
|
13549 |
|
13550 | easeInCubic: function easeInCubic(t) {
|
13551 | return t * t * t;
|
13552 | },
|
13553 |
|
13554 | easeOutCubic: function easeOutCubic(t) {
|
13555 | return --t * t * t + 1;
|
13556 | },
|
13557 |
|
13558 | easeInOutCubic: function easeInOutCubic(t) {
|
13559 | return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
13560 | },
|
13561 |
|
13562 | easeInQuart: function easeInQuart(t) {
|
13563 | return t * t * t * t;
|
13564 | },
|
13565 |
|
13566 | easeOutQuart: function easeOutQuart(t) {
|
13567 | return 1 - --t * t * t * t;
|
13568 | },
|
13569 |
|
13570 | easeInOutQuart: function easeInOutQuart(t) {
|
13571 | return t < .5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
13572 | },
|
13573 |
|
13574 | easeInQuint: function easeInQuint(t) {
|
13575 | return t * t * t * t * t;
|
13576 | },
|
13577 |
|
13578 | easeOutQuint: function easeOutQuint(t) {
|
13579 | return 1 + --t * t * t * t * t;
|
13580 | },
|
13581 |
|
13582 | easeInOutQuint: function easeInOutQuint(t) {
|
13583 | return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
13584 | }
|
13585 | };
|
13586 |
|
13587 | exports.getScrollBarWidth = function () {
|
13588 | var inner = document.createElement('p');
|
13589 | inner.style.width = "100%";
|
13590 | inner.style.height = "200px";
|
13591 | var outer = document.createElement('div');
|
13592 | outer.style.position = "absolute";
|
13593 | outer.style.top = "0px";
|
13594 | outer.style.left = "0px";
|
13595 | outer.style.visibility = "hidden";
|
13596 | outer.style.width = "200px";
|
13597 | outer.style.height = "150px";
|
13598 | outer.style.overflow = "hidden";
|
13599 | outer.appendChild(inner);
|
13600 | document.body.appendChild(outer);
|
13601 | var w1 = inner.offsetWidth;
|
13602 | outer.style.overflow = 'scroll';
|
13603 | var w2 = inner.offsetWidth;
|
13604 | if (w1 == w2) w2 = outer.clientWidth;
|
13605 | document.body.removeChild(outer);
|
13606 | return w1 - w2;
|
13607 | };
|
13608 |
|
13609 | exports.topMost = function (pile, accessors) {
|
13610 | var candidate;
|
13611 |
|
13612 | if (!Array.isArray(accessors)) {
|
13613 | accessors = [accessors];
|
13614 | }
|
13615 |
|
13616 | var _iteratorNormalCompletion = true;
|
13617 | var _didIteratorError = false;
|
13618 | var _iteratorError = undefined;
|
13619 |
|
13620 | try {
|
13621 | for (var _iterator = pile[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
13622 | var member = _step.value;
|
13623 |
|
13624 | if (member) {
|
13625 | candidate = member[accessors[0]];
|
13626 |
|
13627 | for (var i = 1; i < accessors.length; i++) {
|
13628 | if (candidate) {
|
13629 | candidate = candidate[accessors[i]];
|
13630 | }
|
13631 | }
|
13632 |
|
13633 | if (typeof candidate != 'undefined') {
|
13634 | break;
|
13635 | }
|
13636 | }
|
13637 | }
|
13638 | } catch (err) {
|
13639 | _didIteratorError = true;
|
13640 | _iteratorError = err;
|
13641 | } finally {
|
13642 | try {
|
13643 | if (!_iteratorNormalCompletion && _iterator.return != null) {
|
13644 | _iterator.return();
|
13645 | }
|
13646 | } finally {
|
13647 | if (_didIteratorError) {
|
13648 | throw _iteratorError;
|
13649 | }
|
13650 | }
|
13651 | }
|
13652 |
|
13653 | return candidate;
|
13654 | };
|
13655 | });
|
13656 | var esm_1 = esm.isNumber;
|
13657 | var esm_2 = esm.recursiveDOMDelete;
|
13658 | var esm_3 = esm.isString;
|
13659 | var esm_4 = esm.isDate;
|
13660 | var esm_5 = esm.randomUUID;
|
13661 | var esm_6 = esm.fillIfDefined;
|
13662 | var esm_7 = esm.extend;
|
13663 | var esm_8 = esm.selectiveExtend;
|
13664 | var esm_9 = esm.selectiveDeepExtend;
|
13665 | var esm_10 = esm.selectiveNotDeepExtend;
|
13666 | var esm_11 = esm.deepExtend;
|
13667 | var esm_12 = esm.equalArray;
|
13668 | var esm_13 = esm.convert;
|
13669 | var esm_14 = esm.getType;
|
13670 | var esm_15 = esm.copyAndExtendArray;
|
13671 | var esm_16 = esm.copyArray;
|
13672 | var esm_17 = esm.getAbsoluteLeft;
|
13673 | var esm_18 = esm.getAbsoluteRight;
|
13674 | var esm_19 = esm.getAbsoluteTop;
|
13675 | var esm_20 = esm.addClassName;
|
13676 | var esm_21 = esm.removeClassName;
|
13677 | var esm_22 = esm.forEach;
|
13678 | var esm_23 = esm.toArray;
|
13679 | var esm_24 = esm.updateProperty;
|
13680 | var esm_25 = esm.throttle;
|
13681 | var esm_26 = esm.addEventListener;
|
13682 | var esm_27 = esm.removeEventListener;
|
13683 | var esm_28 = esm.preventDefault;
|
13684 | var esm_29 = esm.getTarget;
|
13685 | var esm_30 = esm.hasParent;
|
13686 | var esm_31 = esm.option;
|
13687 | var esm_32 = esm.hexToRGB;
|
13688 | var esm_33 = esm.overrideOpacity;
|
13689 | var esm_34 = esm.RGBToHex;
|
13690 | var esm_35 = esm.parseColor;
|
13691 | var esm_36 = esm.RGBToHSV;
|
13692 | var esm_37 = esm.addCssText;
|
13693 | var esm_38 = esm.removeCssText;
|
13694 | var esm_39 = esm.HSVToRGB;
|
13695 | var esm_40 = esm.HSVToHex;
|
13696 | var esm_41 = esm.hexToHSV;
|
13697 | var esm_42 = esm.isValidHex;
|
13698 | var esm_43 = esm.isValidRGB;
|
13699 | var esm_44 = esm.isValidRGBA;
|
13700 | var esm_45 = esm.selectiveBridgeObject;
|
13701 | var esm_46 = esm.bridgeObject;
|
13702 | var esm_47 = esm.insertSort;
|
13703 | var esm_48 = esm.mergeOptions;
|
13704 | var esm_49 = esm.binarySearchCustom;
|
13705 | var esm_50 = esm.binarySearchValue;
|
13706 | var esm_51 = esm.easingFunctions;
|
13707 | var esm_52 = esm.getScrollBarWidth;
|
13708 | var esm_53 = esm.topMost;
|
13709 |
|
13710 |
|
13711 |
|
13712 |
|
13713 |
|
13714 |
|
13715 |
|
13716 |
|
13717 |
|
13718 |
|
13719 |
|
13720 |
|
13721 |
|
13722 |
|
13723 | function Queue(options) {
|
13724 |
|
13725 | this.delay = null;
|
13726 | this.max = Infinity;
|
13727 |
|
13728 | this._queue = [];
|
13729 | this._timeout = null;
|
13730 | this._extended = null;
|
13731 | this.setOptions(options);
|
13732 | }
|
13733 |
|
13734 |
|
13735 |
|
13736 |
|
13737 |
|
13738 |
|
13739 |
|
13740 |
|
13741 |
|
13742 |
|
13743 |
|
13744 |
|
13745 |
|
13746 |
|
13747 | Queue.prototype.setOptions = function (options) {
|
13748 | if (options && typeof options.delay !== 'undefined') {
|
13749 | this.delay = options.delay;
|
13750 | }
|
13751 |
|
13752 | if (options && typeof options.max !== 'undefined') {
|
13753 | this.max = options.max;
|
13754 | }
|
13755 |
|
13756 | this._flushIfNeeded();
|
13757 | };
|
13758 |
|
13759 |
|
13760 |
|
13761 |
|
13762 |
|
13763 |
|
13764 |
|
13765 |
|
13766 |
|
13767 |
|
13768 |
|
13769 |
|
13770 |
|
13771 |
|
13772 |
|
13773 |
|
13774 |
|
13775 |
|
13776 |
|
13777 |
|
13778 |
|
13779 | Queue.extend = function (object, options) {
|
13780 | var queue = new Queue(options);
|
13781 |
|
13782 | if (object.flush !== undefined) {
|
13783 | throw new Error('Target object already has a property flush');
|
13784 | }
|
13785 |
|
13786 | object.flush = function () {
|
13787 | queue.flush();
|
13788 | };
|
13789 |
|
13790 | var methods = [{
|
13791 | name: 'flush',
|
13792 | original: undefined
|
13793 | }];
|
13794 |
|
13795 | if (options && options.replace) {
|
13796 | for (var i = 0; i < options.replace.length; i++) {
|
13797 | var name = options.replace[i];
|
13798 | methods.push({
|
13799 | name: name,
|
13800 | original: object[name]
|
13801 | });
|
13802 | queue.replace(object, name);
|
13803 | }
|
13804 | }
|
13805 |
|
13806 | queue._extended = {
|
13807 | object: object,
|
13808 | methods: methods
|
13809 | };
|
13810 | return queue;
|
13811 | };
|
13812 |
|
13813 |
|
13814 |
|
13815 |
|
13816 |
|
13817 |
|
13818 | Queue.prototype.destroy = function () {
|
13819 | this.flush();
|
13820 |
|
13821 | if (this._extended) {
|
13822 | var object = this._extended.object;
|
13823 | var methods = this._extended.methods;
|
13824 |
|
13825 | for (var i = 0; i < methods.length; i++) {
|
13826 | var method = methods[i];
|
13827 |
|
13828 | if (method.original) {
|
13829 | object[method.name] = method.original;
|
13830 | } else {
|
13831 | delete object[method.name];
|
13832 | }
|
13833 | }
|
13834 |
|
13835 | this._extended = null;
|
13836 | }
|
13837 | };
|
13838 |
|
13839 |
|
13840 |
|
13841 |
|
13842 |
|
13843 |
|
13844 |
|
13845 | Queue.prototype.replace = function (object, method) {
|
13846 | var me = this;
|
13847 | var original = object[method];
|
13848 |
|
13849 | if (!original) {
|
13850 | throw new Error('Method ' + method + ' undefined');
|
13851 | }
|
13852 |
|
13853 | object[method] = function () {
|
13854 |
|
13855 | var args = [];
|
13856 |
|
13857 | for (var i = 0; i < arguments.length; i++) {
|
13858 | args[i] = arguments[i];
|
13859 | }
|
13860 |
|
13861 |
|
13862 | me.queue({
|
13863 | args: args,
|
13864 | fn: original,
|
13865 | context: this
|
13866 | });
|
13867 | };
|
13868 | };
|
13869 |
|
13870 |
|
13871 |
|
13872 |
|
13873 |
|
13874 |
|
13875 | Queue.prototype.queue = function (entry) {
|
13876 | if (typeof entry === 'function') {
|
13877 | this._queue.push({
|
13878 | fn: entry
|
13879 | });
|
13880 | } else {
|
13881 | this._queue.push(entry);
|
13882 | }
|
13883 |
|
13884 | this._flushIfNeeded();
|
13885 | };
|
13886 |
|
13887 |
|
13888 |
|
13889 |
|
13890 |
|
13891 |
|
13892 | Queue.prototype._flushIfNeeded = function () {
|
13893 |
|
13894 | if (this._queue.length > this.max) {
|
13895 | this.flush();
|
13896 | }
|
13897 |
|
13898 |
|
13899 | clearTimeout(this._timeout);
|
13900 |
|
13901 | if (this.queue.length > 0 && typeof this.delay === 'number') {
|
13902 | var me = this;
|
13903 | this._timeout = setTimeout(function () {
|
13904 | me.flush();
|
13905 | }, this.delay);
|
13906 | }
|
13907 | };
|
13908 |
|
13909 |
|
13910 |
|
13911 |
|
13912 |
|
13913 | Queue.prototype.flush = function () {
|
13914 | while (this._queue.length > 0) {
|
13915 | var entry = this._queue.shift();
|
13916 |
|
13917 | entry.fn.apply(entry.context || entry.fn, entry.args || []);
|
13918 | }
|
13919 | };
|
13920 |
|
13921 | var Queue_1 = Queue;
|
13922 |
|
13923 |
|
13924 |
|
13925 |
|
13926 |
|
13927 |
|
13928 |
|
13929 |
|
13930 |
|
13931 |
|
13932 |
|
13933 |
|
13934 |
|
13935 |
|
13936 |
|
13937 |
|
13938 |
|
13939 |
|
13940 |
|
13941 |
|
13942 |
|
13943 |
|
13944 |
|
13945 |
|
13946 |
|
13947 |
|
13948 |
|
13949 |
|
13950 |
|
13951 |
|
13952 |
|
13953 |
|
13954 |
|
13955 |
|
13956 |
|
13957 |
|
13958 |
|
13959 |
|
13960 |
|
13961 |
|
13962 |
|
13963 |
|
13964 |
|
13965 |
|
13966 | function DataSet(data, options) {
|
13967 |
|
13968 | if (data && !Array.isArray(data)) {
|
13969 | options = data;
|
13970 | data = null;
|
13971 | }
|
13972 |
|
13973 | this._options = options || {};
|
13974 | this._data = {};
|
13975 |
|
13976 | this.length = 0;
|
13977 |
|
13978 | this._fieldId = this._options.fieldId || 'id';
|
13979 |
|
13980 | this._type = {};
|
13981 |
|
13982 |
|
13983 |
|
13984 | if (this._options.type) {
|
13985 | var fields = Object.keys(this._options.type);
|
13986 |
|
13987 | for (var i = 0, len = fields.length; i < len; i++) {
|
13988 | var field = fields[i];
|
13989 | var value = this._options.type[field];
|
13990 |
|
13991 | if (value == 'Date' || value == 'ISODate' || value == 'ASPDate') {
|
13992 | this._type[field] = 'Date';
|
13993 | } else {
|
13994 | this._type[field] = value;
|
13995 | }
|
13996 | }
|
13997 | }
|
13998 |
|
13999 | this._subscribers = {};
|
14000 |
|
14001 |
|
14002 | if (data) {
|
14003 | this.add(data);
|
14004 | }
|
14005 |
|
14006 | this.setOptions(options);
|
14007 | }
|
14008 |
|
14009 |
|
14010 |
|
14011 |
|
14012 |
|
14013 |
|
14014 |
|
14015 |
|
14016 |
|
14017 |
|
14018 | DataSet.prototype.setOptions = function (options) {
|
14019 | if (options && options.queue !== undefined) {
|
14020 | if (options.queue === false) {
|
14021 |
|
14022 | if (this._queue) {
|
14023 | this._queue.destroy();
|
14024 |
|
14025 | delete this._queue;
|
14026 | }
|
14027 | } else {
|
14028 |
|
14029 | if (!this._queue) {
|
14030 | this._queue = Queue_1.extend(this, {
|
14031 | replace: ['add', 'update', 'remove']
|
14032 | });
|
14033 | }
|
14034 |
|
14035 | if (_typeof$1(options.queue) === 'object') {
|
14036 | this._queue.setOptions(options.queue);
|
14037 | }
|
14038 | }
|
14039 | }
|
14040 | };
|
14041 |
|
14042 |
|
14043 |
|
14044 |
|
14045 |
|
14046 |
|
14047 |
|
14048 |
|
14049 |
|
14050 |
|
14051 |
|
14052 | DataSet.prototype.on = function (event, callback) {
|
14053 | var subscribers = this._subscribers[event];
|
14054 |
|
14055 | if (!subscribers) {
|
14056 | subscribers = [];
|
14057 | this._subscribers[event] = subscribers;
|
14058 | }
|
14059 |
|
14060 | subscribers.push({
|
14061 | callback: callback
|
14062 | });
|
14063 | };
|
14064 |
|
14065 |
|
14066 |
|
14067 |
|
14068 |
|
14069 |
|
14070 |
|
14071 | DataSet.prototype.off = function (event, callback) {
|
14072 | var subscribers = this._subscribers[event];
|
14073 |
|
14074 | if (subscribers) {
|
14075 | this._subscribers[event] = subscribers.filter(function (listener) {
|
14076 | return listener.callback != callback;
|
14077 | });
|
14078 | }
|
14079 | };
|
14080 |
|
14081 |
|
14082 |
|
14083 |
|
14084 |
|
14085 |
|
14086 |
|
14087 |
|
14088 |
|
14089 | DataSet.prototype._trigger = function (event, params, senderId) {
|
14090 | if (event == '*') {
|
14091 | throw new Error('Cannot trigger event *');
|
14092 | }
|
14093 |
|
14094 | var subscribers = [];
|
14095 |
|
14096 | if (event in this._subscribers) {
|
14097 | subscribers = subscribers.concat(this._subscribers[event]);
|
14098 | }
|
14099 |
|
14100 | if ('*' in this._subscribers) {
|
14101 | subscribers = subscribers.concat(this._subscribers['*']);
|
14102 | }
|
14103 |
|
14104 | for (var i = 0, len = subscribers.length; i < len; i++) {
|
14105 | var subscriber = subscribers[i];
|
14106 |
|
14107 | if (subscriber.callback) {
|
14108 | subscriber.callback(event, params, senderId || null);
|
14109 | }
|
14110 | }
|
14111 | };
|
14112 |
|
14113 |
|
14114 |
|
14115 |
|
14116 |
|
14117 |
|
14118 |
|
14119 |
|
14120 |
|
14121 | DataSet.prototype.add = function (data, senderId) {
|
14122 | var addedIds = [],
|
14123 | id,
|
14124 | me = this;
|
14125 |
|
14126 | if (Array.isArray(data)) {
|
14127 |
|
14128 | for (var i = 0, len = data.length; i < len; i++) {
|
14129 | id = me._addItem(data[i]);
|
14130 | addedIds.push(id);
|
14131 | }
|
14132 | } else if (data && _typeof$1(data) === 'object') {
|
14133 |
|
14134 | id = me._addItem(data);
|
14135 | addedIds.push(id);
|
14136 | } else {
|
14137 | throw new Error('Unknown dataType');
|
14138 | }
|
14139 |
|
14140 | if (addedIds.length) {
|
14141 | this._trigger('add', {
|
14142 | items: addedIds
|
14143 | }, senderId);
|
14144 | }
|
14145 |
|
14146 | return addedIds;
|
14147 | };
|
14148 |
|
14149 |
|
14150 |
|
14151 |
|
14152 |
|
14153 |
|
14154 |
|
14155 |
|
14156 |
|
14157 | DataSet.prototype.update = function (data, senderId) {
|
14158 | var addedIds = [];
|
14159 | var updatedIds = [];
|
14160 | var oldData = [];
|
14161 | var updatedData = [];
|
14162 | var me = this;
|
14163 | var fieldId = me._fieldId;
|
14164 |
|
14165 | var addOrUpdate = function addOrUpdate(item) {
|
14166 | var id = item[fieldId];
|
14167 |
|
14168 | if (me._data[id]) {
|
14169 | var oldItem = esm.extend({}, me._data[id]);
|
14170 |
|
14171 | id = me._updateItem(item);
|
14172 | updatedIds.push(id);
|
14173 | updatedData.push(item);
|
14174 | oldData.push(oldItem);
|
14175 | } else {
|
14176 |
|
14177 | id = me._addItem(item);
|
14178 | addedIds.push(id);
|
14179 | }
|
14180 | };
|
14181 |
|
14182 | if (Array.isArray(data)) {
|
14183 |
|
14184 | for (var i = 0, len = data.length; i < len; i++) {
|
14185 | if (data[i] && _typeof$1(data[i]) === 'object') {
|
14186 | addOrUpdate(data[i]);
|
14187 | } else {
|
14188 | console.warn('Ignoring input item, which is not an object at index ' + i);
|
14189 | }
|
14190 | }
|
14191 | } else if (data && _typeof$1(data) === 'object') {
|
14192 |
|
14193 | addOrUpdate(data);
|
14194 | } else {
|
14195 | throw new Error('Unknown dataType');
|
14196 | }
|
14197 |
|
14198 | if (addedIds.length) {
|
14199 | this._trigger('add', {
|
14200 | items: addedIds
|
14201 | }, senderId);
|
14202 | }
|
14203 |
|
14204 | if (updatedIds.length) {
|
14205 | var props = {
|
14206 | items: updatedIds,
|
14207 | oldData: oldData,
|
14208 | data: updatedData
|
14209 | };
|
14210 |
|
14211 |
|
14212 |
|
14213 |
|
14214 |
|
14215 |
|
14216 |
|
14217 | this._trigger('update', props, senderId);
|
14218 | }
|
14219 |
|
14220 | return addedIds.concat(updatedIds);
|
14221 | };
|
14222 |
|
14223 |
|
14224 |
|
14225 |
|
14226 |
|
14227 |
|
14228 |
|
14229 |
|
14230 |
|
14231 |
|
14232 |
|
14233 |
|
14234 |
|
14235 |
|
14236 |
|
14237 |
|
14238 |
|
14239 |
|
14240 |
|
14241 |
|
14242 |
|
14243 |
|
14244 |
|
14245 |
|
14246 |
|
14247 |
|
14248 |
|
14249 |
|
14250 |
|
14251 |
|
14252 |
|
14253 | DataSet.prototype.get = function (args) {
|
14254 |
|
14255 | var me = this;
|
14256 |
|
14257 | var id, ids, options;
|
14258 | var firstType = esm.getType(arguments[0]);
|
14259 |
|
14260 | if (firstType == 'String' || firstType == 'Number') {
|
14261 |
|
14262 | id = arguments[0];
|
14263 | options = arguments[1];
|
14264 | } else if (firstType == 'Array') {
|
14265 |
|
14266 | ids = arguments[0];
|
14267 | options = arguments[1];
|
14268 | } else {
|
14269 |
|
14270 | options = arguments[0];
|
14271 | }
|
14272 |
|
14273 |
|
14274 | var returnType;
|
14275 |
|
14276 | if (options && options.returnType) {
|
14277 | var allowedValues = ['Array', 'Object'];
|
14278 | returnType = allowedValues.indexOf(options.returnType) == -1 ? 'Array' : options.returnType;
|
14279 | } else {
|
14280 | returnType = 'Array';
|
14281 | }
|
14282 |
|
14283 |
|
14284 | var type = options && options.type || this._options.type;
|
14285 | var filter = options && options.filter;
|
14286 | var items = [],
|
14287 | item,
|
14288 | itemIds,
|
14289 | itemId,
|
14290 | i,
|
14291 | len;
|
14292 |
|
14293 | if (id != undefined) {
|
14294 |
|
14295 | item = me._getItem(id, type);
|
14296 |
|
14297 | if (item && filter && !filter(item)) {
|
14298 | item = null;
|
14299 | }
|
14300 | } else if (ids != undefined) {
|
14301 |
|
14302 | for (i = 0, len = ids.length; i < len; i++) {
|
14303 | item = me._getItem(ids[i], type);
|
14304 |
|
14305 | if (!filter || filter(item)) {
|
14306 | items.push(item);
|
14307 | }
|
14308 | }
|
14309 | } else {
|
14310 |
|
14311 | itemIds = Object.keys(this._data);
|
14312 |
|
14313 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14314 | itemId = itemIds[i];
|
14315 | item = me._getItem(itemId, type);
|
14316 |
|
14317 | if (!filter || filter(item)) {
|
14318 | items.push(item);
|
14319 | }
|
14320 | }
|
14321 | }
|
14322 |
|
14323 |
|
14324 | if (options && options.order && id == undefined) {
|
14325 | this._sort(items, options.order);
|
14326 | }
|
14327 |
|
14328 |
|
14329 | if (options && options.fields) {
|
14330 | var fields = options.fields;
|
14331 |
|
14332 | if (id != undefined) {
|
14333 | item = this._filterFields(item, fields);
|
14334 | } else {
|
14335 | for (i = 0, len = items.length; i < len; i++) {
|
14336 | items[i] = this._filterFields(items[i], fields);
|
14337 | }
|
14338 | }
|
14339 | }
|
14340 |
|
14341 |
|
14342 | if (returnType == 'Object') {
|
14343 | var result = {},
|
14344 | resultant;
|
14345 |
|
14346 | for (i = 0, len = items.length; i < len; i++) {
|
14347 | resultant = items[i];
|
14348 | result[resultant.id] = resultant;
|
14349 | }
|
14350 |
|
14351 | return result;
|
14352 | } else {
|
14353 | if (id != undefined) {
|
14354 |
|
14355 | return item;
|
14356 | } else {
|
14357 |
|
14358 | return items;
|
14359 | }
|
14360 | }
|
14361 | };
|
14362 |
|
14363 |
|
14364 |
|
14365 |
|
14366 |
|
14367 |
|
14368 |
|
14369 |
|
14370 |
|
14371 |
|
14372 | DataSet.prototype.getIds = function (options) {
|
14373 | var data = this._data,
|
14374 | filter = options && options.filter,
|
14375 | order = options && options.order,
|
14376 | type = options && options.type || this._options.type,
|
14377 | itemIds = Object.keys(data),
|
14378 | i,
|
14379 | len,
|
14380 | id,
|
14381 | item,
|
14382 | items,
|
14383 | ids = [];
|
14384 |
|
14385 | if (filter) {
|
14386 |
|
14387 | if (order) {
|
14388 |
|
14389 | items = [];
|
14390 |
|
14391 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14392 | id = itemIds[i];
|
14393 | item = this._getItem(id, type);
|
14394 |
|
14395 | if (filter(item)) {
|
14396 | items.push(item);
|
14397 | }
|
14398 | }
|
14399 |
|
14400 | this._sort(items, order);
|
14401 |
|
14402 | for (i = 0, len = items.length; i < len; i++) {
|
14403 | ids.push(items[i][this._fieldId]);
|
14404 | }
|
14405 | } else {
|
14406 |
|
14407 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14408 | id = itemIds[i];
|
14409 | item = this._getItem(id, type);
|
14410 |
|
14411 | if (filter(item)) {
|
14412 | ids.push(item[this._fieldId]);
|
14413 | }
|
14414 | }
|
14415 | }
|
14416 | } else {
|
14417 |
|
14418 | if (order) {
|
14419 |
|
14420 | items = [];
|
14421 |
|
14422 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14423 | id = itemIds[i];
|
14424 | items.push(data[id]);
|
14425 | }
|
14426 |
|
14427 | this._sort(items, order);
|
14428 |
|
14429 | for (i = 0, len = items.length; i < len; i++) {
|
14430 | ids.push(items[i][this._fieldId]);
|
14431 | }
|
14432 | } else {
|
14433 |
|
14434 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14435 | id = itemIds[i];
|
14436 | item = data[id];
|
14437 | ids.push(item[this._fieldId]);
|
14438 | }
|
14439 | }
|
14440 | }
|
14441 |
|
14442 | return ids;
|
14443 | };
|
14444 |
|
14445 |
|
14446 |
|
14447 |
|
14448 |
|
14449 |
|
14450 |
|
14451 | DataSet.prototype.getDataSet = function () {
|
14452 | return this;
|
14453 | };
|
14454 |
|
14455 |
|
14456 |
|
14457 |
|
14458 |
|
14459 |
|
14460 |
|
14461 |
|
14462 |
|
14463 |
|
14464 |
|
14465 |
|
14466 | DataSet.prototype.forEach = function (callback, options) {
|
14467 | var filter = options && options.filter,
|
14468 | type = options && options.type || this._options.type,
|
14469 | data = this._data,
|
14470 | itemIds = Object.keys(data),
|
14471 | i,
|
14472 | len,
|
14473 | item,
|
14474 | id;
|
14475 |
|
14476 | if (options && options.order) {
|
14477 |
|
14478 | var items = this.get(options);
|
14479 |
|
14480 | for (i = 0, len = items.length; i < len; i++) {
|
14481 | item = items[i];
|
14482 | id = item[this._fieldId];
|
14483 | callback(item, id);
|
14484 | }
|
14485 | } else {
|
14486 |
|
14487 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14488 | id = itemIds[i];
|
14489 | item = this._getItem(id, type);
|
14490 |
|
14491 | if (!filter || filter(item)) {
|
14492 | callback(item, id);
|
14493 | }
|
14494 | }
|
14495 | }
|
14496 | };
|
14497 |
|
14498 |
|
14499 |
|
14500 |
|
14501 |
|
14502 |
|
14503 |
|
14504 |
|
14505 |
|
14506 |
|
14507 |
|
14508 |
|
14509 |
|
14510 | DataSet.prototype.map = function (callback, options) {
|
14511 | var filter = options && options.filter,
|
14512 | type = options && options.type || this._options.type,
|
14513 | mappedItems = [],
|
14514 | data = this._data,
|
14515 | itemIds = Object.keys(data),
|
14516 | i,
|
14517 | len,
|
14518 | id,
|
14519 | item;
|
14520 |
|
14521 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14522 | id = itemIds[i];
|
14523 | item = this._getItem(id, type);
|
14524 |
|
14525 | if (!filter || filter(item)) {
|
14526 | mappedItems.push(callback(item, id));
|
14527 | }
|
14528 | }
|
14529 |
|
14530 |
|
14531 | if (options && options.order) {
|
14532 | this._sort(mappedItems, options.order);
|
14533 | }
|
14534 |
|
14535 | return mappedItems;
|
14536 | };
|
14537 |
|
14538 |
|
14539 |
|
14540 |
|
14541 |
|
14542 |
|
14543 |
|
14544 |
|
14545 |
|
14546 | DataSet.prototype._filterFields = function (item, fields) {
|
14547 | if (!item) {
|
14548 |
|
14549 | return item;
|
14550 | }
|
14551 |
|
14552 | var filteredItem = {},
|
14553 | itemFields = Object.keys(item),
|
14554 | len = itemFields.length,
|
14555 | i,
|
14556 | field;
|
14557 |
|
14558 | if (Array.isArray(fields)) {
|
14559 | for (i = 0; i < len; i++) {
|
14560 | field = itemFields[i];
|
14561 |
|
14562 | if (fields.indexOf(field) != -1) {
|
14563 | filteredItem[field] = item[field];
|
14564 | }
|
14565 | }
|
14566 | } else {
|
14567 | for (i = 0; i < len; i++) {
|
14568 | field = itemFields[i];
|
14569 |
|
14570 | if (fields.hasOwnProperty(field)) {
|
14571 | filteredItem[fields[field]] = item[field];
|
14572 | }
|
14573 | }
|
14574 | }
|
14575 |
|
14576 | return filteredItem;
|
14577 | };
|
14578 |
|
14579 |
|
14580 |
|
14581 |
|
14582 |
|
14583 |
|
14584 |
|
14585 |
|
14586 | DataSet.prototype._sort = function (items, order) {
|
14587 | if (esm.isString(order)) {
|
14588 |
|
14589 | var name = order;
|
14590 |
|
14591 | items.sort(function (a, b) {
|
14592 | var av = a[name];
|
14593 | var bv = b[name];
|
14594 | return av > bv ? 1 : av < bv ? -1 : 0;
|
14595 | });
|
14596 | } else if (typeof order === 'function') {
|
14597 |
|
14598 | items.sort(order);
|
14599 | }
|
14600 |
|
14601 | else {
|
14602 | throw new TypeError('Order must be a function or a string');
|
14603 | }
|
14604 | };
|
14605 |
|
14606 |
|
14607 |
|
14608 |
|
14609 |
|
14610 |
|
14611 |
|
14612 |
|
14613 |
|
14614 | DataSet.prototype.remove = function (id, senderId) {
|
14615 | var removedIds = [],
|
14616 | removedItems = [],
|
14617 | ids = [],
|
14618 | i,
|
14619 | len,
|
14620 | itemId,
|
14621 | item;
|
14622 |
|
14623 | ids = Array.isArray(id) ? id : [id];
|
14624 |
|
14625 | for (i = 0, len = ids.length; i < len; i++) {
|
14626 | item = this._remove(ids[i]);
|
14627 |
|
14628 | if (item) {
|
14629 | itemId = item[this._fieldId];
|
14630 |
|
14631 | if (itemId != undefined) {
|
14632 | removedIds.push(itemId);
|
14633 | removedItems.push(item);
|
14634 | }
|
14635 | }
|
14636 | }
|
14637 |
|
14638 | if (removedIds.length) {
|
14639 | this._trigger('remove', {
|
14640 | items: removedIds,
|
14641 | oldData: removedItems
|
14642 | }, senderId);
|
14643 | }
|
14644 |
|
14645 | return removedIds;
|
14646 | };
|
14647 |
|
14648 |
|
14649 |
|
14650 |
|
14651 |
|
14652 |
|
14653 |
|
14654 |
|
14655 | DataSet.prototype._remove = function (id) {
|
14656 | var item, ident;
|
14657 |
|
14658 | if (esm.isNumber(id) || esm.isString(id)) {
|
14659 | ident = id;
|
14660 | } else if (id && _typeof$1(id) === 'object') {
|
14661 | ident = id[this._fieldId];
|
14662 | }
|
14663 |
|
14664 |
|
14665 | if (ident !== undefined && this._data[ident]) {
|
14666 | item = this._data[ident];
|
14667 | delete this._data[ident];
|
14668 | this.length--;
|
14669 | return item;
|
14670 | }
|
14671 |
|
14672 | return null;
|
14673 | };
|
14674 |
|
14675 |
|
14676 |
|
14677 |
|
14678 |
|
14679 |
|
14680 |
|
14681 | DataSet.prototype.clear = function (senderId) {
|
14682 | var i, len;
|
14683 | var ids = Object.keys(this._data);
|
14684 | var items = [];
|
14685 |
|
14686 | for (i = 0, len = ids.length; i < len; i++) {
|
14687 | items.push(this._data[ids[i]]);
|
14688 | }
|
14689 |
|
14690 | this._data = {};
|
14691 | this.length = 0;
|
14692 |
|
14693 | this._trigger('remove', {
|
14694 | items: ids,
|
14695 | oldData: items
|
14696 | }, senderId);
|
14697 |
|
14698 | return ids;
|
14699 | };
|
14700 |
|
14701 |
|
14702 |
|
14703 |
|
14704 |
|
14705 |
|
14706 |
|
14707 | DataSet.prototype.max = function (field) {
|
14708 | var data = this._data,
|
14709 | itemIds = Object.keys(data),
|
14710 | max = null,
|
14711 | maxField = null,
|
14712 | i,
|
14713 | len;
|
14714 |
|
14715 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14716 | var id = itemIds[i];
|
14717 | var item = data[id];
|
14718 | var itemField = item[field];
|
14719 |
|
14720 | if (itemField != null && (!max || itemField > maxField)) {
|
14721 | max = item;
|
14722 | maxField = itemField;
|
14723 | }
|
14724 | }
|
14725 |
|
14726 | return max;
|
14727 | };
|
14728 |
|
14729 |
|
14730 |
|
14731 |
|
14732 |
|
14733 |
|
14734 |
|
14735 | DataSet.prototype.min = function (field) {
|
14736 | var data = this._data,
|
14737 | itemIds = Object.keys(data),
|
14738 | min = null,
|
14739 | minField = null,
|
14740 | i,
|
14741 | len;
|
14742 |
|
14743 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14744 | var id = itemIds[i];
|
14745 | var item = data[id];
|
14746 | var itemField = item[field];
|
14747 |
|
14748 | if (itemField != null && (!min || itemField < minField)) {
|
14749 | min = item;
|
14750 | minField = itemField;
|
14751 | }
|
14752 | }
|
14753 |
|
14754 | return min;
|
14755 | };
|
14756 |
|
14757 |
|
14758 |
|
14759 |
|
14760 |
|
14761 |
|
14762 |
|
14763 |
|
14764 |
|
14765 | DataSet.prototype.distinct = function (field) {
|
14766 | var data = this._data;
|
14767 | var itemIds = Object.keys(data);
|
14768 | var values = [];
|
14769 | var fieldType = this._options.type && this._options.type[field] || null;
|
14770 | var count = 0;
|
14771 | var i, j, len;
|
14772 |
|
14773 | for (i = 0, len = itemIds.length; i < len; i++) {
|
14774 | var id = itemIds[i];
|
14775 | var item = data[id];
|
14776 | var value = item[field];
|
14777 | var exists = false;
|
14778 |
|
14779 | for (j = 0; j < count; j++) {
|
14780 | if (values[j] == value) {
|
14781 | exists = true;
|
14782 | break;
|
14783 | }
|
14784 | }
|
14785 |
|
14786 | if (!exists && value !== undefined) {
|
14787 | values[count] = value;
|
14788 | count++;
|
14789 | }
|
14790 | }
|
14791 |
|
14792 | if (fieldType) {
|
14793 | for (i = 0, len = values.length; i < len; i++) {
|
14794 | values[i] = esm.convert(values[i], fieldType);
|
14795 | }
|
14796 | }
|
14797 |
|
14798 | return values;
|
14799 | };
|
14800 |
|
14801 |
|
14802 |
|
14803 |
|
14804 |
|
14805 |
|
14806 |
|
14807 |
|
14808 | DataSet.prototype._addItem = function (item) {
|
14809 | var id = item[this._fieldId];
|
14810 |
|
14811 | if (id != undefined) {
|
14812 |
|
14813 | if (this._data[id]) {
|
14814 |
|
14815 | throw new Error('Cannot add item: item with id ' + id + ' already exists');
|
14816 | }
|
14817 | } else {
|
14818 |
|
14819 | id = esm.randomUUID();
|
14820 | item[this._fieldId] = id;
|
14821 | }
|
14822 |
|
14823 | var d = {},
|
14824 | fields = Object.keys(item),
|
14825 | i,
|
14826 | len;
|
14827 |
|
14828 | for (i = 0, len = fields.length; i < len; i++) {
|
14829 | var field = fields[i];
|
14830 | var fieldType = this._type[field];
|
14831 |
|
14832 | d[field] = esm.convert(item[field], fieldType);
|
14833 | }
|
14834 |
|
14835 | this._data[id] = d;
|
14836 | this.length++;
|
14837 | return id;
|
14838 | };
|
14839 |
|
14840 |
|
14841 |
|
14842 |
|
14843 |
|
14844 |
|
14845 |
|
14846 |
|
14847 |
|
14848 | DataSet.prototype._getItem = function (id, types) {
|
14849 | var field, value, i, len;
|
14850 |
|
14851 | var raw = this._data[id];
|
14852 |
|
14853 | if (!raw) {
|
14854 | return null;
|
14855 | }
|
14856 |
|
14857 |
|
14858 | var converted = {},
|
14859 | fields = Object.keys(raw);
|
14860 |
|
14861 | if (types) {
|
14862 | for (i = 0, len = fields.length; i < len; i++) {
|
14863 | field = fields[i];
|
14864 | value = raw[field];
|
14865 | converted[field] = esm.convert(value, types[field]);
|
14866 | }
|
14867 | } else {
|
14868 |
|
14869 | for (i = 0, len = fields.length; i < len; i++) {
|
14870 | field = fields[i];
|
14871 | value = raw[field];
|
14872 | converted[field] = value;
|
14873 | }
|
14874 | }
|
14875 |
|
14876 | if (!converted[this._fieldId]) {
|
14877 | converted[this._fieldId] = raw.id;
|
14878 | }
|
14879 |
|
14880 | return converted;
|
14881 | };
|
14882 |
|
14883 |
|
14884 |
|
14885 |
|
14886 |
|
14887 |
|
14888 |
|
14889 |
|
14890 |
|
14891 |
|
14892 | DataSet.prototype._updateItem = function (item) {
|
14893 | var id = item[this._fieldId];
|
14894 |
|
14895 | if (id == undefined) {
|
14896 | throw new Error('Cannot update item: item has no id (item: ' + JSON.stringify(item) + ')');
|
14897 | }
|
14898 |
|
14899 | var d = this._data[id];
|
14900 |
|
14901 | if (!d) {
|
14902 |
|
14903 | throw new Error('Cannot update item: no item with id ' + id + ' found');
|
14904 | }
|
14905 |
|
14906 |
|
14907 | var fields = Object.keys(item);
|
14908 |
|
14909 | for (var i = 0, len = fields.length; i < len; i++) {
|
14910 | var field = fields[i];
|
14911 | var fieldType = this._type[field];
|
14912 |
|
14913 | d[field] = esm.convert(item[field], fieldType);
|
14914 | }
|
14915 |
|
14916 | return id;
|
14917 | };
|
14918 |
|
14919 | var DataSet_1 = DataSet;
|
14920 |
|
14921 |
|
14922 |
|
14923 |
|
14924 |
|
14925 |
|
14926 |
|
14927 |
|
14928 |
|
14929 |
|
14930 |
|
14931 | function DataView(data, options) {
|
14932 | this._data = null;
|
14933 | this._ids = {};
|
14934 |
|
14935 | this.length = 0;
|
14936 |
|
14937 | this._options = options || {};
|
14938 | this._fieldId = 'id';
|
14939 |
|
14940 | this._subscribers = {};
|
14941 |
|
14942 | var me = this;
|
14943 |
|
14944 | this.listener = function () {
|
14945 | me._onEvent.apply(me, arguments);
|
14946 | };
|
14947 |
|
14948 | this.setData(data);
|
14949 | }
|
14950 |
|
14951 |
|
14952 |
|
14953 |
|
14954 |
|
14955 |
|
14956 |
|
14957 |
|
14958 | DataView.prototype.setData = function (data) {
|
14959 | var ids, id, i, len, items;
|
14960 |
|
14961 | if (this._data) {
|
14962 |
|
14963 | if (this._data.off) {
|
14964 | this._data.off('*', this.listener);
|
14965 | }
|
14966 |
|
14967 |
|
14968 | ids = this._data.getIds({
|
14969 | filter: this._options && this._options.filter
|
14970 | });
|
14971 | items = [];
|
14972 |
|
14973 | for (i = 0, len = ids.length; i < len; i++) {
|
14974 | items.push(this._data._data[ids[i]]);
|
14975 | }
|
14976 |
|
14977 | this._ids = {};
|
14978 | this.length = 0;
|
14979 |
|
14980 | this._trigger('remove', {
|
14981 | items: ids,
|
14982 | oldData: items
|
14983 | });
|
14984 | }
|
14985 |
|
14986 | this._data = data;
|
14987 |
|
14988 | if (this._data) {
|
14989 |
|
14990 | this._fieldId = this._options.fieldId || this._data && this._data.options && this._data.options.fieldId || 'id';
|
14991 |
|
14992 | ids = this._data.getIds({
|
14993 | filter: this._options && this._options.filter
|
14994 | });
|
14995 |
|
14996 | for (i = 0, len = ids.length; i < len; i++) {
|
14997 | id = ids[i];
|
14998 | this._ids[id] = true;
|
14999 | }
|
15000 |
|
15001 | this.length = ids.length;
|
15002 |
|
15003 | this._trigger('add', {
|
15004 | items: ids
|
15005 | });
|
15006 |
|
15007 |
|
15008 | if (this._data.on) {
|
15009 | this._data.on('*', this.listener);
|
15010 | }
|
15011 | }
|
15012 | };
|
15013 |
|
15014 |
|
15015 |
|
15016 |
|
15017 |
|
15018 |
|
15019 | DataView.prototype.refresh = function () {
|
15020 | var id, i, len;
|
15021 |
|
15022 | var ids = this._data.getIds({
|
15023 | filter: this._options && this._options.filter
|
15024 | }),
|
15025 | oldIds = Object.keys(this._ids),
|
15026 | newIds = {},
|
15027 | addedIds = [],
|
15028 | removedIds = [],
|
15029 | removedItems = [];
|
15030 |
|
15031 |
|
15032 | for (i = 0, len = ids.length; i < len; i++) {
|
15033 | id = ids[i];
|
15034 | newIds[id] = true;
|
15035 |
|
15036 | if (!this._ids[id]) {
|
15037 | addedIds.push(id);
|
15038 | this._ids[id] = true;
|
15039 | }
|
15040 | }
|
15041 |
|
15042 |
|
15043 | for (i = 0, len = oldIds.length; i < len; i++) {
|
15044 | id = oldIds[i];
|
15045 |
|
15046 | if (!newIds[id]) {
|
15047 | removedIds.push(id);
|
15048 | removedItems.push(this._data._data[id]);
|
15049 | delete this._ids[id];
|
15050 | }
|
15051 | }
|
15052 |
|
15053 | this.length += addedIds.length - removedIds.length;
|
15054 |
|
15055 | if (addedIds.length) {
|
15056 | this._trigger('add', {
|
15057 | items: addedIds
|
15058 | });
|
15059 | }
|
15060 |
|
15061 | if (removedIds.length) {
|
15062 | this._trigger('remove', {
|
15063 | items: removedIds,
|
15064 | oldData: removedItems
|
15065 | });
|
15066 | }
|
15067 | };
|
15068 |
|
15069 |
|
15070 |
|
15071 |
|
15072 |
|
15073 |
|
15074 |
|
15075 |
|
15076 |
|
15077 |
|
15078 |
|
15079 |
|
15080 |
|
15081 |
|
15082 |
|
15083 |
|
15084 |
|
15085 |
|
15086 |
|
15087 |
|
15088 |
|
15089 |
|
15090 |
|
15091 |
|
15092 |
|
15093 |
|
15094 |
|
15095 |
|
15096 |
|
15097 |
|
15098 |
|
15099 |
|
15100 |
|
15101 |
|
15102 |
|
15103 |
|
15104 |
|
15105 | DataView.prototype.get = function (args) {
|
15106 |
|
15107 | var me = this;
|
15108 |
|
15109 | var ids, options, data;
|
15110 | var firstType = esm.getType(arguments[0]);
|
15111 |
|
15112 | if (firstType == 'String' || firstType == 'Number' || firstType == 'Array') {
|
15113 |
|
15114 | ids = arguments[0];
|
15115 |
|
15116 | options = arguments[1];
|
15117 | data = arguments[2];
|
15118 | } else {
|
15119 |
|
15120 | options = arguments[0];
|
15121 | data = arguments[1];
|
15122 | }
|
15123 |
|
15124 |
|
15125 | var viewOptions = esm.extend({}, this._options, options);
|
15126 |
|
15127 | if (this._options.filter && options && options.filter) {
|
15128 | viewOptions.filter = function (item) {
|
15129 | return me._options.filter(item) && options.filter(item);
|
15130 | };
|
15131 | }
|
15132 |
|
15133 |
|
15134 | var getArguments = [];
|
15135 |
|
15136 | if (ids != undefined) {
|
15137 | getArguments.push(ids);
|
15138 | }
|
15139 |
|
15140 | getArguments.push(viewOptions);
|
15141 | getArguments.push(data);
|
15142 | return this._data && this._data.get.apply(this._data, getArguments);
|
15143 | };
|
15144 |
|
15145 |
|
15146 |
|
15147 |
|
15148 |
|
15149 |
|
15150 |
|
15151 |
|
15152 |
|
15153 |
|
15154 | DataView.prototype.getIds = function (options) {
|
15155 | var ids;
|
15156 |
|
15157 | if (this._data) {
|
15158 | var defaultFilter = this._options.filter;
|
15159 | var filter;
|
15160 |
|
15161 | if (options && options.filter) {
|
15162 | if (defaultFilter) {
|
15163 | filter = function filter(item) {
|
15164 | return defaultFilter(item) && options.filter(item);
|
15165 | };
|
15166 | } else {
|
15167 | filter = options.filter;
|
15168 | }
|
15169 | } else {
|
15170 | filter = defaultFilter;
|
15171 | }
|
15172 |
|
15173 | ids = this._data.getIds({
|
15174 | filter: filter,
|
15175 | order: options && options.order
|
15176 | });
|
15177 | } else {
|
15178 | ids = [];
|
15179 | }
|
15180 |
|
15181 | return ids;
|
15182 | };
|
15183 |
|
15184 |
|
15185 |
|
15186 |
|
15187 |
|
15188 |
|
15189 |
|
15190 |
|
15191 |
|
15192 |
|
15193 |
|
15194 |
|
15195 | DataView.prototype.forEach = function (callback, options) {
|
15196 | if (this._data) {
|
15197 | var defaultFilter = this._options.filter;
|
15198 | var filter;
|
15199 |
|
15200 | if (options && options.filter) {
|
15201 | if (defaultFilter) {
|
15202 | filter = function filter(item) {
|
15203 | return defaultFilter(item) && options.filter(item);
|
15204 | };
|
15205 | } else {
|
15206 | filter = options.filter;
|
15207 | }
|
15208 | } else {
|
15209 | filter = defaultFilter;
|
15210 | }
|
15211 |
|
15212 | this._data.forEach(callback, {
|
15213 | filter: filter,
|
15214 | order: options && options.order
|
15215 | });
|
15216 | }
|
15217 | };
|
15218 |
|
15219 |
|
15220 |
|
15221 |
|
15222 |
|
15223 |
|
15224 |
|
15225 |
|
15226 |
|
15227 |
|
15228 |
|
15229 |
|
15230 |
|
15231 | DataView.prototype.map = function (callback, options) {
|
15232 | var mappedItems = [];
|
15233 |
|
15234 | if (this._data) {
|
15235 | var defaultFilter = this._options.filter;
|
15236 | var filter;
|
15237 |
|
15238 | if (options && options.filter) {
|
15239 | if (defaultFilter) {
|
15240 | filter = function filter(item) {
|
15241 | return defaultFilter(item) && options.filter(item);
|
15242 | };
|
15243 | } else {
|
15244 | filter = options.filter;
|
15245 | }
|
15246 | } else {
|
15247 | filter = defaultFilter;
|
15248 | }
|
15249 |
|
15250 | mappedItems = this._data.map(callback, {
|
15251 | filter: filter,
|
15252 | order: options && options.order
|
15253 | });
|
15254 | } else {
|
15255 | mappedItems = [];
|
15256 | }
|
15257 |
|
15258 | return mappedItems;
|
15259 | };
|
15260 |
|
15261 |
|
15262 |
|
15263 |
|
15264 |
|
15265 |
|
15266 |
|
15267 | DataView.prototype.getDataSet = function () {
|
15268 | var dataSet = this;
|
15269 |
|
15270 | while (dataSet instanceof DataView) {
|
15271 | dataSet = dataSet._data;
|
15272 | }
|
15273 |
|
15274 | return dataSet || null;
|
15275 | };
|
15276 |
|
15277 |
|
15278 |
|
15279 |
|
15280 |
|
15281 |
|
15282 |
|
15283 |
|
15284 |
|
15285 |
|
15286 |
|
15287 | DataView.prototype._onEvent = function (event, params, senderId) {
|
15288 | var i, len, id, item;
|
15289 | var ids = params && params.items;
|
15290 | var addedIds = [],
|
15291 | updatedIds = [],
|
15292 | removedIds = [],
|
15293 | oldItems = [],
|
15294 | updatedItems = [],
|
15295 | removedItems = [];
|
15296 |
|
15297 | if (ids && this._data) {
|
15298 | switch (event) {
|
15299 | case 'add':
|
15300 |
|
15301 | for (i = 0, len = ids.length; i < len; i++) {
|
15302 | id = ids[i];
|
15303 | item = this.get(id);
|
15304 |
|
15305 | if (item) {
|
15306 | this._ids[id] = true;
|
15307 | addedIds.push(id);
|
15308 | }
|
15309 | }
|
15310 |
|
15311 | break;
|
15312 |
|
15313 | case 'update':
|
15314 |
|
15315 |
|
15316 | for (i = 0, len = ids.length; i < len; i++) {
|
15317 | id = ids[i];
|
15318 | item = this.get(id);
|
15319 |
|
15320 | if (item) {
|
15321 | if (this._ids[id]) {
|
15322 | updatedIds.push(id);
|
15323 | updatedItems.push(params.data[i]);
|
15324 | oldItems.push(params.oldData[i]);
|
15325 | } else {
|
15326 | this._ids[id] = true;
|
15327 | addedIds.push(id);
|
15328 | }
|
15329 | } else {
|
15330 | if (this._ids[id]) {
|
15331 | delete this._ids[id];
|
15332 | removedIds.push(id);
|
15333 | removedItems.push(params.oldData[i]);
|
15334 | }
|
15335 | }
|
15336 | }
|
15337 |
|
15338 | break;
|
15339 |
|
15340 | case 'remove':
|
15341 |
|
15342 | for (i = 0, len = ids.length; i < len; i++) {
|
15343 | id = ids[i];
|
15344 |
|
15345 | if (this._ids[id]) {
|
15346 | delete this._ids[id];
|
15347 | removedIds.push(id);
|
15348 | removedItems.push(params.oldData[i]);
|
15349 | }
|
15350 | }
|
15351 |
|
15352 | break;
|
15353 | }
|
15354 |
|
15355 | this.length += addedIds.length - removedIds.length;
|
15356 |
|
15357 | if (addedIds.length) {
|
15358 | this._trigger('add', {
|
15359 | items: addedIds
|
15360 | }, senderId);
|
15361 | }
|
15362 |
|
15363 | if (updatedIds.length) {
|
15364 | this._trigger('update', {
|
15365 | items: updatedIds,
|
15366 | oldData: oldItems,
|
15367 | data: updatedItems
|
15368 | }, senderId);
|
15369 | }
|
15370 |
|
15371 | if (removedIds.length) {
|
15372 | this._trigger('remove', {
|
15373 | items: removedIds,
|
15374 | oldData: removedItems
|
15375 | }, senderId);
|
15376 | }
|
15377 | }
|
15378 | };
|
15379 |
|
15380 |
|
15381 | DataView.prototype.on = DataSet_1.prototype.on;
|
15382 | DataView.prototype.off = DataSet_1.prototype.off;
|
15383 | DataView.prototype._trigger = DataSet_1.prototype._trigger;
|
15384 |
|
15385 | DataView.prototype.subscribe = DataView.prototype.on;
|
15386 | DataView.prototype.unsubscribe = DataView.prototype.off;
|
15387 | var _DataView = DataView;
|
15388 | var DataSet$1 = DataSet_1;
|
15389 | var DataView$1 = _DataView;
|
15390 | var Queue$1 = Queue_1;
|
15391 | var visData = {
|
15392 | DataSet: DataSet$1,
|
15393 | DataView: DataView$1,
|
15394 | Queue: Queue$1
|
15395 | };
|
15396 |
|
15397 |
|
15398 |
|
15399 |
|
15400 | var emitterComponent = Emitter;
|
15401 |
|
15402 |
|
15403 |
|
15404 |
|
15405 |
|
15406 |
|
15407 | function Emitter(obj) {
|
15408 | if (obj) return mixin(obj);
|
15409 | }
|
15410 |
|
15411 |
|
15412 |
|
15413 |
|
15414 |
|
15415 |
|
15416 |
|
15417 |
|
15418 | function mixin(obj) {
|
15419 | for (var key in Emitter.prototype) {
|
15420 | obj[key] = Emitter.prototype[key];
|
15421 | }
|
15422 |
|
15423 | return obj;
|
15424 | }
|
15425 |
|
15426 |
|
15427 |
|
15428 |
|
15429 |
|
15430 |
|
15431 |
|
15432 |
|
15433 |
|
15434 |
|
15435 | Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
|
15436 | this._callbacks = this._callbacks || {};
|
15437 | (this._callbacks[event] = this._callbacks[event] || []).push(fn);
|
15438 | return this;
|
15439 | };
|
15440 |
|
15441 |
|
15442 |
|
15443 |
|
15444 |
|
15445 |
|
15446 |
|
15447 |
|
15448 |
|
15449 |
|
15450 |
|
15451 | Emitter.prototype.once = function (event, fn) {
|
15452 | var self = this;
|
15453 | this._callbacks = this._callbacks || {};
|
15454 |
|
15455 | function on() {
|
15456 | self.off(event, on);
|
15457 | fn.apply(this, arguments);
|
15458 | }
|
15459 |
|
15460 | on.fn = fn;
|
15461 | this.on(event, on);
|
15462 | return this;
|
15463 | };
|
15464 |
|
15465 |
|
15466 |
|
15467 |
|
15468 |
|
15469 |
|
15470 |
|
15471 |
|
15472 |
|
15473 |
|
15474 |
|
15475 | Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
|
15476 | this._callbacks = this._callbacks || {};
|
15477 |
|
15478 | if (0 == arguments.length) {
|
15479 | this._callbacks = {};
|
15480 | return this;
|
15481 | }
|
15482 |
|
15483 |
|
15484 | var callbacks = this._callbacks[event];
|
15485 | if (!callbacks) return this;
|
15486 |
|
15487 | if (1 == arguments.length) {
|
15488 | delete this._callbacks[event];
|
15489 | return this;
|
15490 | }
|
15491 |
|
15492 |
|
15493 | var cb;
|
15494 |
|
15495 | for (var i = 0; i < callbacks.length; i++) {
|
15496 | cb = callbacks[i];
|
15497 |
|
15498 | if (cb === fn || cb.fn === fn) {
|
15499 | callbacks.splice(i, 1);
|
15500 | break;
|
15501 | }
|
15502 | }
|
15503 |
|
15504 | return this;
|
15505 | };
|
15506 |
|
15507 |
|
15508 |
|
15509 |
|
15510 |
|
15511 |
|
15512 |
|
15513 |
|
15514 |
|
15515 | Emitter.prototype.emit = function (event) {
|
15516 | this._callbacks = this._callbacks || {};
|
15517 | var args = [].slice.call(arguments, 1),
|
15518 | callbacks = this._callbacks[event];
|
15519 |
|
15520 | if (callbacks) {
|
15521 | callbacks = callbacks.slice(0);
|
15522 |
|
15523 | for (var i = 0, len = callbacks.length; i < len; ++i) {
|
15524 | callbacks[i].apply(this, args);
|
15525 | }
|
15526 | }
|
15527 |
|
15528 | return this;
|
15529 | };
|
15530 |
|
15531 |
|
15532 |
|
15533 |
|
15534 |
|
15535 |
|
15536 |
|
15537 |
|
15538 |
|
15539 | Emitter.prototype.listeners = function (event) {
|
15540 | this._callbacks = this._callbacks || {};
|
15541 | return this._callbacks[event] || [];
|
15542 | };
|
15543 |
|
15544 |
|
15545 |
|
15546 |
|
15547 |
|
15548 |
|
15549 |
|
15550 |
|
15551 |
|
15552 | Emitter.prototype.hasListeners = function (event) {
|
15553 | return !!this.listeners(event).length;
|
15554 | };
|
15555 |
|
15556 |
|
15557 |
|
15558 |
|
15559 |
|
15560 |
|
15561 |
|
15562 | function Point3d(x, y, z) {
|
15563 | this.x = x !== undefined ? x : 0;
|
15564 | this.y = y !== undefined ? y : 0;
|
15565 | this.z = z !== undefined ? z : 0;
|
15566 | }
|
15567 |
|
15568 |
|
15569 |
|
15570 |
|
15571 |
|
15572 |
|
15573 |
|
15574 |
|
15575 | Point3d.subtract = function (a, b) {
|
15576 | var sub = new Point3d();
|
15577 | sub.x = a.x - b.x;
|
15578 | sub.y = a.y - b.y;
|
15579 | sub.z = a.z - b.z;
|
15580 | return sub;
|
15581 | };
|
15582 |
|
15583 |
|
15584 |
|
15585 |
|
15586 |
|
15587 |
|
15588 |
|
15589 |
|
15590 | Point3d.add = function (a, b) {
|
15591 | var sum = new Point3d();
|
15592 | sum.x = a.x + b.x;
|
15593 | sum.y = a.y + b.y;
|
15594 | sum.z = a.z + b.z;
|
15595 | return sum;
|
15596 | };
|
15597 |
|
15598 |
|
15599 |
|
15600 |
|
15601 |
|
15602 |
|
15603 |
|
15604 |
|
15605 | Point3d.avg = function (a, b) {
|
15606 | return new Point3d((a.x + b.x) / 2, (a.y + b.y) / 2, (a.z + b.z) / 2);
|
15607 | };
|
15608 |
|
15609 |
|
15610 |
|
15611 |
|
15612 |
|
15613 |
|
15614 |
|
15615 |
|
15616 |
|
15617 | Point3d.crossProduct = function (a, b) {
|
15618 | var crossproduct = new Point3d();
|
15619 | crossproduct.x = a.y * b.z - a.z * b.y;
|
15620 | crossproduct.y = a.z * b.x - a.x * b.z;
|
15621 | crossproduct.z = a.x * b.y - a.y * b.x;
|
15622 | return crossproduct;
|
15623 | };
|
15624 |
|
15625 |
|
15626 |
|
15627 |
|
15628 |
|
15629 |
|
15630 | Point3d.prototype.length = function () {
|
15631 | return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
15632 | };
|
15633 |
|
15634 | var Point3d_1 = Point3d;
|
15635 |
|
15636 |
|
15637 |
|
15638 |
|
15639 |
|
15640 |
|
15641 | function Point2d(x, y) {
|
15642 | this.x = x !== undefined ? x : 0;
|
15643 | this.y = y !== undefined ? y : 0;
|
15644 | }
|
15645 |
|
15646 | var Point2d_1 = Point2d;
|
15647 |
|
15648 |
|
15649 |
|
15650 |
|
15651 |
|
15652 |
|
15653 |
|
15654 |
|
15655 |
|
15656 |
|
15657 |
|
15658 | function Slider(container, options) {
|
15659 | if (container === undefined) {
|
15660 | throw new Error('No container element defined');
|
15661 | }
|
15662 |
|
15663 | this.container = container;
|
15664 | this.visible = options && options.visible != undefined ? options.visible : true;
|
15665 |
|
15666 | if (this.visible) {
|
15667 | this.frame = document.createElement('DIV');
|
15668 |
|
15669 | this.frame.style.width = '100%';
|
15670 | this.frame.style.position = 'relative';
|
15671 | this.container.appendChild(this.frame);
|
15672 | this.frame.prev = document.createElement('INPUT');
|
15673 | this.frame.prev.type = 'BUTTON';
|
15674 | this.frame.prev.value = 'Prev';
|
15675 | this.frame.appendChild(this.frame.prev);
|
15676 | this.frame.play = document.createElement('INPUT');
|
15677 | this.frame.play.type = 'BUTTON';
|
15678 | this.frame.play.value = 'Play';
|
15679 | this.frame.appendChild(this.frame.play);
|
15680 | this.frame.next = document.createElement('INPUT');
|
15681 | this.frame.next.type = 'BUTTON';
|
15682 | this.frame.next.value = 'Next';
|
15683 | this.frame.appendChild(this.frame.next);
|
15684 | this.frame.bar = document.createElement('INPUT');
|
15685 | this.frame.bar.type = 'BUTTON';
|
15686 | this.frame.bar.style.position = 'absolute';
|
15687 | this.frame.bar.style.border = '1px solid red';
|
15688 | this.frame.bar.style.width = '100px';
|
15689 | this.frame.bar.style.height = '6px';
|
15690 | this.frame.bar.style.borderRadius = '2px';
|
15691 | this.frame.bar.style.MozBorderRadius = '2px';
|
15692 | this.frame.bar.style.border = '1px solid #7F7F7F';
|
15693 | this.frame.bar.style.backgroundColor = '#E5E5E5';
|
15694 | this.frame.appendChild(this.frame.bar);
|
15695 | this.frame.slide = document.createElement('INPUT');
|
15696 | this.frame.slide.type = 'BUTTON';
|
15697 | this.frame.slide.style.margin = '0px';
|
15698 | this.frame.slide.value = ' ';
|
15699 | this.frame.slide.style.position = 'relative';
|
15700 | this.frame.slide.style.left = '-100px';
|
15701 | this.frame.appendChild(this.frame.slide);
|
15702 |
|
15703 | var me = this;
|
15704 |
|
15705 | this.frame.slide.onmousedown = function (event) {
|
15706 | me._onMouseDown(event);
|
15707 | };
|
15708 |
|
15709 | this.frame.prev.onclick = function (event) {
|
15710 | me.prev(event);
|
15711 | };
|
15712 |
|
15713 | this.frame.play.onclick = function (event) {
|
15714 | me.togglePlay(event);
|
15715 | };
|
15716 |
|
15717 | this.frame.next.onclick = function (event) {
|
15718 | me.next(event);
|
15719 | };
|
15720 | }
|
15721 |
|
15722 | this.onChangeCallback = undefined;
|
15723 | this.values = [];
|
15724 | this.index = undefined;
|
15725 | this.playTimeout = undefined;
|
15726 | this.playInterval = 1000;
|
15727 |
|
15728 | this.playLoop = true;
|
15729 | }
|
15730 |
|
15731 |
|
15732 |
|
15733 |
|
15734 |
|
15735 | Slider.prototype.prev = function () {
|
15736 | var index = this.getIndex();
|
15737 |
|
15738 | if (index > 0) {
|
15739 | index--;
|
15740 | this.setIndex(index);
|
15741 | }
|
15742 | };
|
15743 |
|
15744 |
|
15745 |
|
15746 |
|
15747 |
|
15748 | Slider.prototype.next = function () {
|
15749 | var index = this.getIndex();
|
15750 |
|
15751 | if (index < this.values.length - 1) {
|
15752 | index++;
|
15753 | this.setIndex(index);
|
15754 | }
|
15755 | };
|
15756 |
|
15757 |
|
15758 |
|
15759 |
|
15760 |
|
15761 | Slider.prototype.playNext = function () {
|
15762 | var start = new Date();
|
15763 | var index = this.getIndex();
|
15764 |
|
15765 | if (index < this.values.length - 1) {
|
15766 | index++;
|
15767 | this.setIndex(index);
|
15768 | } else if (this.playLoop) {
|
15769 |
|
15770 | index = 0;
|
15771 | this.setIndex(index);
|
15772 | }
|
15773 |
|
15774 | var end = new Date();
|
15775 | var diff = end - start;
|
15776 |
|
15777 |
|
15778 | var interval = Math.max(this.playInterval - diff, 0);
|
15779 |
|
15780 | var me = this;
|
15781 | this.playTimeout = setTimeout(function () {
|
15782 | me.playNext();
|
15783 | }, interval);
|
15784 | };
|
15785 |
|
15786 |
|
15787 |
|
15788 |
|
15789 |
|
15790 | Slider.prototype.togglePlay = function () {
|
15791 | if (this.playTimeout === undefined) {
|
15792 | this.play();
|
15793 | } else {
|
15794 | this.stop();
|
15795 | }
|
15796 | };
|
15797 |
|
15798 |
|
15799 |
|
15800 |
|
15801 |
|
15802 | Slider.prototype.play = function () {
|
15803 |
|
15804 | if (this.playTimeout) return;
|
15805 | this.playNext();
|
15806 |
|
15807 | if (this.frame) {
|
15808 | this.frame.play.value = 'Stop';
|
15809 | }
|
15810 | };
|
15811 |
|
15812 |
|
15813 |
|
15814 |
|
15815 |
|
15816 | Slider.prototype.stop = function () {
|
15817 | clearInterval(this.playTimeout);
|
15818 | this.playTimeout = undefined;
|
15819 |
|
15820 | if (this.frame) {
|
15821 | this.frame.play.value = 'Play';
|
15822 | }
|
15823 | };
|
15824 |
|
15825 |
|
15826 |
|
15827 |
|
15828 |
|
15829 |
|
15830 |
|
15831 |
|
15832 | Slider.prototype.setOnChangeCallback = function (callback) {
|
15833 | this.onChangeCallback = callback;
|
15834 | };
|
15835 |
|
15836 |
|
15837 |
|
15838 |
|
15839 |
|
15840 |
|
15841 | Slider.prototype.setPlayInterval = function (interval) {
|
15842 | this.playInterval = interval;
|
15843 | };
|
15844 |
|
15845 |
|
15846 |
|
15847 |
|
15848 |
|
15849 |
|
15850 | Slider.prototype.getPlayInterval = function () {
|
15851 | return this.playInterval;
|
15852 | };
|
15853 |
|
15854 |
|
15855 |
|
15856 |
|
15857 |
|
15858 |
|
15859 |
|
15860 |
|
15861 |
|
15862 | Slider.prototype.setPlayLoop = function (doLoop) {
|
15863 | this.playLoop = doLoop;
|
15864 | };
|
15865 |
|
15866 |
|
15867 |
|
15868 |
|
15869 |
|
15870 | Slider.prototype.onChange = function () {
|
15871 | if (this.onChangeCallback !== undefined) {
|
15872 | this.onChangeCallback();
|
15873 | }
|
15874 | };
|
15875 |
|
15876 |
|
15877 |
|
15878 |
|
15879 |
|
15880 | Slider.prototype.redraw = function () {
|
15881 | if (this.frame) {
|
15882 |
|
15883 | this.frame.bar.style.top = this.frame.clientHeight / 2 - this.frame.bar.offsetHeight / 2 + 'px';
|
15884 | this.frame.bar.style.width = this.frame.clientWidth - this.frame.prev.clientWidth - this.frame.play.clientWidth - this.frame.next.clientWidth - 30 + 'px';
|
15885 |
|
15886 | var left = this.indexToLeft(this.index);
|
15887 | this.frame.slide.style.left = left + 'px';
|
15888 | }
|
15889 | };
|
15890 |
|
15891 |
|
15892 |
|
15893 |
|
15894 |
|
15895 |
|
15896 | Slider.prototype.setValues = function (values) {
|
15897 | this.values = values;
|
15898 | if (this.values.length > 0) this.setIndex(0);else this.index = undefined;
|
15899 | };
|
15900 |
|
15901 |
|
15902 |
|
15903 |
|
15904 |
|
15905 |
|
15906 | Slider.prototype.setIndex = function (index) {
|
15907 | if (index < this.values.length) {
|
15908 | this.index = index;
|
15909 | this.redraw();
|
15910 | this.onChange();
|
15911 | } else {
|
15912 | throw new Error('Index out of range');
|
15913 | }
|
15914 | };
|
15915 |
|
15916 |
|
15917 |
|
15918 |
|
15919 |
|
15920 |
|
15921 | Slider.prototype.getIndex = function () {
|
15922 | return this.index;
|
15923 | };
|
15924 |
|
15925 |
|
15926 |
|
15927 |
|
15928 |
|
15929 |
|
15930 | Slider.prototype.get = function () {
|
15931 | return this.values[this.index];
|
15932 | };
|
15933 |
|
15934 | Slider.prototype._onMouseDown = function (event) {
|
15935 |
|
15936 | var leftButtonDown = event.which ? event.which === 1 : event.button === 1;
|
15937 | if (!leftButtonDown) return;
|
15938 | this.startClientX = event.clientX;
|
15939 | this.startSlideX = parseFloat(this.frame.slide.style.left);
|
15940 | this.frame.style.cursor = 'move';
|
15941 |
|
15942 |
|
15943 |
|
15944 | var me = this;
|
15945 |
|
15946 | this.onmousemove = function (event) {
|
15947 | me._onMouseMove(event);
|
15948 | };
|
15949 |
|
15950 | this.onmouseup = function (event) {
|
15951 | me._onMouseUp(event);
|
15952 | };
|
15953 |
|
15954 | util.addEventListener(document, 'mousemove', this.onmousemove);
|
15955 | util.addEventListener(document, 'mouseup', this.onmouseup);
|
15956 | util.preventDefault(event);
|
15957 | };
|
15958 |
|
15959 | Slider.prototype.leftToIndex = function (left) {
|
15960 | var width = parseFloat(this.frame.bar.style.width) - this.frame.slide.clientWidth - 10;
|
15961 | var x = left - 3;
|
15962 | var index = Math.round(x / width * (this.values.length - 1));
|
15963 | if (index < 0) index = 0;
|
15964 | if (index > this.values.length - 1) index = this.values.length - 1;
|
15965 | return index;
|
15966 | };
|
15967 |
|
15968 | Slider.prototype.indexToLeft = function (index) {
|
15969 | var width = parseFloat(this.frame.bar.style.width) - this.frame.slide.clientWidth - 10;
|
15970 | var x = index / (this.values.length - 1) * width;
|
15971 | var left = x + 3;
|
15972 | return left;
|
15973 | };
|
15974 |
|
15975 | Slider.prototype._onMouseMove = function (event) {
|
15976 | var diff = event.clientX - this.startClientX;
|
15977 | var x = this.startSlideX + diff;
|
15978 | var index = this.leftToIndex(x);
|
15979 | this.setIndex(index);
|
15980 | util.preventDefault();
|
15981 | };
|
15982 |
|
15983 | Slider.prototype._onMouseUp = function (event) {
|
15984 |
|
15985 | this.frame.style.cursor = 'auto';
|
15986 |
|
15987 | util.removeEventListener(document, 'mousemove', this.onmousemove);
|
15988 | util.removeEventListener(document, 'mouseup', this.onmouseup);
|
15989 | util.preventDefault();
|
15990 | };
|
15991 |
|
15992 | var Slider_1 = Slider;
|
15993 |
|
15994 |
|
15995 |
|
15996 |
|
15997 |
|
15998 |
|
15999 |
|
16000 |
|
16001 |
|
16002 |
|
16003 |
|
16004 |
|
16005 |
|
16006 |
|
16007 |
|
16008 |
|
16009 |
|
16010 |
|
16011 |
|
16012 |
|
16013 |
|
16014 |
|
16015 |
|
16016 |
|
16017 |
|
16018 |
|
16019 | function StepNumber(start, end, step, prettyStep) {
|
16020 |
|
16021 | this._start = 0;
|
16022 | this._end = 0;
|
16023 | this._step = 1;
|
16024 | this.prettyStep = true;
|
16025 | this.precision = 5;
|
16026 | this._current = 0;
|
16027 | this.setRange(start, end, step, prettyStep);
|
16028 | }
|
16029 |
|
16030 |
|
16031 |
|
16032 |
|
16033 |
|
16034 |
|
16035 |
|
16036 |
|
16037 |
|
16038 |
|
16039 | StepNumber.prototype.isNumeric = function (n) {
|
16040 | return !isNaN(parseFloat(n)) && isFinite(n);
|
16041 | };
|
16042 |
|
16043 |
|
16044 |
|
16045 |
|
16046 |
|
16047 |
|
16048 |
|
16049 |
|
16050 |
|
16051 |
|
16052 |
|
16053 | StepNumber.prototype.setRange = function (start, end, step, prettyStep) {
|
16054 | if (!this.isNumeric(start)) {
|
16055 | throw new Error('Parameter \'start\' is not numeric; value: ' + start);
|
16056 | }
|
16057 |
|
16058 | if (!this.isNumeric(end)) {
|
16059 | throw new Error('Parameter \'end\' is not numeric; value: ' + start);
|
16060 | }
|
16061 |
|
16062 | if (!this.isNumeric(step)) {
|
16063 | throw new Error('Parameter \'step\' is not numeric; value: ' + start);
|
16064 | }
|
16065 |
|
16066 | this._start = start ? start : 0;
|
16067 | this._end = end ? end : 0;
|
16068 | this.setStep(step, prettyStep);
|
16069 | };
|
16070 |
|
16071 |
|
16072 |
|
16073 |
|
16074 |
|
16075 |
|
16076 |
|
16077 |
|
16078 | StepNumber.prototype.setStep = function (step, prettyStep) {
|
16079 | if (step === undefined || step <= 0) return;
|
16080 | if (prettyStep !== undefined) this.prettyStep = prettyStep;
|
16081 | if (this.prettyStep === true) this._step = StepNumber.calculatePrettyStep(step);else this._step = step;
|
16082 | };
|
16083 |
|
16084 |
|
16085 |
|
16086 |
|
16087 |
|
16088 |
|
16089 |
|
16090 |
|
16091 |
|
16092 | StepNumber.calculatePrettyStep = function (step) {
|
16093 | var log10 = function log10(x) {
|
16094 | return Math.log(x) / Math.LN10;
|
16095 | };
|
16096 |
|
16097 |
|
16098 | var step1 = Math.pow(10, Math.round(log10(step))),
|
16099 | step2 = 2 * Math.pow(10, Math.round(log10(step / 2))),
|
16100 | step5 = 5 * Math.pow(10, Math.round(log10(step / 5)));
|
16101 |
|
16102 | var prettyStep = step1;
|
16103 | if (Math.abs(step2 - step) <= Math.abs(prettyStep - step)) prettyStep = step2;
|
16104 | if (Math.abs(step5 - step) <= Math.abs(prettyStep - step)) prettyStep = step5;
|
16105 |
|
16106 | if (prettyStep <= 0) {
|
16107 | prettyStep = 1;
|
16108 | }
|
16109 |
|
16110 | return prettyStep;
|
16111 | };
|
16112 |
|
16113 |
|
16114 |
|
16115 |
|
16116 |
|
16117 |
|
16118 | StepNumber.prototype.getCurrent = function () {
|
16119 | return parseFloat(this._current.toPrecision(this.precision));
|
16120 | };
|
16121 |
|
16122 |
|
16123 |
|
16124 |
|
16125 |
|
16126 |
|
16127 | StepNumber.prototype.getStep = function () {
|
16128 | return this._step;
|
16129 | };
|
16130 |
|
16131 |
|
16132 |
|
16133 |
|
16134 |
|
16135 |
|
16136 |
|
16137 |
|
16138 |
|
16139 |
|
16140 |
|
16141 |
|
16142 |
|
16143 | StepNumber.prototype.start = function (checkFirst) {
|
16144 | if (checkFirst === undefined) {
|
16145 | checkFirst = false;
|
16146 | }
|
16147 |
|
16148 | this._current = this._start - this._start % this._step;
|
16149 |
|
16150 | if (checkFirst) {
|
16151 | if (this.getCurrent() < this._start) {
|
16152 | this.next();
|
16153 | }
|
16154 | }
|
16155 | };
|
16156 |
|
16157 |
|
16158 |
|
16159 |
|
16160 |
|
16161 | StepNumber.prototype.next = function () {
|
16162 | this._current += this._step;
|
16163 | };
|
16164 |
|
16165 |
|
16166 |
|
16167 |
|
16168 |
|
16169 |
|
16170 | StepNumber.prototype.end = function () {
|
16171 | return this._current > this._end;
|
16172 | };
|
16173 |
|
16174 | var StepNumber_1 = StepNumber;
|
16175 |
|
16176 | function _typeof$2(obj) {
|
16177 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
16178 | _typeof$2 = function (obj) {
|
16179 | return typeof obj;
|
16180 | };
|
16181 | } else {
|
16182 | _typeof$2 = function (obj) {
|
16183 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
16184 | };
|
16185 | }
|
16186 |
|
16187 | return _typeof$2(obj);
|
16188 | }
|
16189 |
|
16190 | function _classCallCheck(instance, Constructor) {
|
16191 | if (!(instance instanceof Constructor)) {
|
16192 | throw new TypeError("Cannot call a class as a function");
|
16193 | }
|
16194 | }
|
16195 |
|
16196 | function _defineProperties(target, props) {
|
16197 | for (var i = 0; i < props.length; i++) {
|
16198 | var descriptor = props[i];
|
16199 | descriptor.enumerable = descriptor.enumerable || false;
|
16200 | descriptor.configurable = true;
|
16201 | if ("value" in descriptor) descriptor.writable = true;
|
16202 | Object.defineProperty(target, descriptor.key, descriptor);
|
16203 | }
|
16204 | }
|
16205 |
|
16206 | function _createClass(Constructor, protoProps, staticProps) {
|
16207 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
16208 | if (staticProps) _defineProperties(Constructor, staticProps);
|
16209 | return Constructor;
|
16210 | }
|
16211 |
|
16212 |
|
16213 |
|
16214 |
|
16215 |
|
16216 |
|
16217 |
|
16218 |
|
16219 |
|
16220 |
|
16221 |
|
16222 |
|
16223 | function Camera() {
|
16224 | this.armLocation = new Point3d_1();
|
16225 | this.armRotation = {};
|
16226 | this.armRotation.horizontal = 0;
|
16227 | this.armRotation.vertical = 0;
|
16228 | this.armLength = 1.7;
|
16229 | this.cameraOffset = new Point3d_1();
|
16230 | this.offsetMultiplier = 0.6;
|
16231 | this.cameraLocation = new Point3d_1();
|
16232 | this.cameraRotation = new Point3d_1(0.5 * Math.PI, 0, 0);
|
16233 | this.calculateCameraOrientation();
|
16234 | }
|
16235 |
|
16236 |
|
16237 |
|
16238 |
|
16239 |
|
16240 |
|
16241 |
|
16242 | Camera.prototype.setOffset = function (x, y) {
|
16243 | var abs = Math.abs,
|
16244 | sign = Math.sign,
|
16245 | mul = this.offsetMultiplier,
|
16246 | border = this.armLength * mul;
|
16247 |
|
16248 | if (abs(x) > border) {
|
16249 | x = sign(x) * border;
|
16250 | }
|
16251 |
|
16252 | if (abs(y) > border) {
|
16253 | y = sign(y) * border;
|
16254 | }
|
16255 |
|
16256 | this.cameraOffset.x = x;
|
16257 | this.cameraOffset.y = y;
|
16258 | this.calculateCameraOrientation();
|
16259 | };
|
16260 |
|
16261 |
|
16262 |
|
16263 |
|
16264 |
|
16265 |
|
16266 | Camera.prototype.getOffset = function () {
|
16267 | return this.cameraOffset;
|
16268 | };
|
16269 |
|
16270 |
|
16271 |
|
16272 |
|
16273 |
|
16274 |
|
16275 |
|
16276 |
|
16277 | Camera.prototype.setArmLocation = function (x, y, z) {
|
16278 | this.armLocation.x = x;
|
16279 | this.armLocation.y = y;
|
16280 | this.armLocation.z = z;
|
16281 | this.calculateCameraOrientation();
|
16282 | };
|
16283 |
|
16284 |
|
16285 |
|
16286 |
|
16287 |
|
16288 |
|
16289 |
|
16290 |
|
16291 |
|
16292 |
|
16293 | Camera.prototype.setArmRotation = function (horizontal, vertical) {
|
16294 | if (horizontal !== undefined) {
|
16295 | this.armRotation.horizontal = horizontal;
|
16296 | }
|
16297 |
|
16298 | if (vertical !== undefined) {
|
16299 | this.armRotation.vertical = vertical;
|
16300 | if (this.armRotation.vertical < 0) this.armRotation.vertical = 0;
|
16301 | if (this.armRotation.vertical > 0.5 * Math.PI) this.armRotation.vertical = 0.5 * Math.PI;
|
16302 | }
|
16303 |
|
16304 | if (horizontal !== undefined || vertical !== undefined) {
|
16305 | this.calculateCameraOrientation();
|
16306 | }
|
16307 | };
|
16308 |
|
16309 |
|
16310 |
|
16311 |
|
16312 |
|
16313 |
|
16314 | Camera.prototype.getArmRotation = function () {
|
16315 | var rot = {};
|
16316 | rot.horizontal = this.armRotation.horizontal;
|
16317 | rot.vertical = this.armRotation.vertical;
|
16318 | return rot;
|
16319 | };
|
16320 |
|
16321 |
|
16322 |
|
16323 |
|
16324 |
|
16325 |
|
16326 | Camera.prototype.setArmLength = function (length) {
|
16327 | if (length === undefined) return;
|
16328 | this.armLength = length;
|
16329 |
|
16330 |
|
16331 |
|
16332 | if (this.armLength < 0.71) this.armLength = 0.71;
|
16333 | if (this.armLength > 5.0) this.armLength = 5.0;
|
16334 | this.setOffset(this.cameraOffset.x, this.cameraOffset.y);
|
16335 | this.calculateCameraOrientation();
|
16336 | };
|
16337 |
|
16338 |
|
16339 |
|
16340 |
|
16341 |
|
16342 |
|
16343 | Camera.prototype.getArmLength = function () {
|
16344 | return this.armLength;
|
16345 | };
|
16346 |
|
16347 |
|
16348 |
|
16349 |
|
16350 |
|
16351 |
|
16352 | Camera.prototype.getCameraLocation = function () {
|
16353 | return this.cameraLocation;
|
16354 | };
|
16355 |
|
16356 |
|
16357 |
|
16358 |
|
16359 |
|
16360 |
|
16361 | Camera.prototype.getCameraRotation = function () {
|
16362 | return this.cameraRotation;
|
16363 | };
|
16364 |
|
16365 |
|
16366 |
|
16367 |
|
16368 |
|
16369 |
|
16370 | Camera.prototype.calculateCameraOrientation = function () {
|
16371 |
|
16372 | this.cameraLocation.x = this.armLocation.x - this.armLength * Math.sin(this.armRotation.horizontal) * Math.cos(this.armRotation.vertical);
|
16373 | this.cameraLocation.y = this.armLocation.y - this.armLength * Math.cos(this.armRotation.horizontal) * Math.cos(this.armRotation.vertical);
|
16374 | this.cameraLocation.z = this.armLocation.z + this.armLength * Math.sin(this.armRotation.vertical);
|
16375 |
|
16376 | this.cameraRotation.x = Math.PI / 2 - this.armRotation.vertical;
|
16377 | this.cameraRotation.y = 0;
|
16378 | this.cameraRotation.z = -this.armRotation.horizontal;
|
16379 | var xa = this.cameraRotation.x;
|
16380 | var za = this.cameraRotation.z;
|
16381 | var dx = this.cameraOffset.x;
|
16382 | var dy = this.cameraOffset.y;
|
16383 | var sin = Math.sin,
|
16384 | cos = Math.cos;
|
16385 | this.cameraLocation.x = this.cameraLocation.x + dx * cos(za) + dy * -sin(za) * cos(xa);
|
16386 | this.cameraLocation.y = this.cameraLocation.y + dx * sin(za) + dy * cos(za) * cos(xa);
|
16387 | this.cameraLocation.z = this.cameraLocation.z + dy * sin(xa);
|
16388 | };
|
16389 |
|
16390 | var Camera_1 = Camera;
|
16391 |
|
16392 |
|
16393 |
|
16394 |
|
16395 |
|
16396 |
|
16397 | var STYLE = {
|
16398 | BAR: 0,
|
16399 | BARCOLOR: 1,
|
16400 | BARSIZE: 2,
|
16401 | DOT: 3,
|
16402 | DOTLINE: 4,
|
16403 | DOTCOLOR: 5,
|
16404 | DOTSIZE: 6,
|
16405 | GRID: 7,
|
16406 | LINE: 8,
|
16407 | SURFACE: 9
|
16408 | };
|
16409 |
|
16410 | var STYLENAME = {
|
16411 | 'dot': STYLE.DOT,
|
16412 | 'dot-line': STYLE.DOTLINE,
|
16413 | 'dot-color': STYLE.DOTCOLOR,
|
16414 | 'dot-size': STYLE.DOTSIZE,
|
16415 | 'line': STYLE.LINE,
|
16416 | 'grid': STYLE.GRID,
|
16417 | 'surface': STYLE.SURFACE,
|
16418 | 'bar': STYLE.BAR,
|
16419 | 'bar-color': STYLE.BARCOLOR,
|
16420 | 'bar-size': STYLE.BARSIZE
|
16421 | };
|
16422 |
|
16423 |
|
16424 |
|
16425 |
|
16426 |
|
16427 |
|
16428 |
|
16429 | var OPTIONKEYS = ['width', 'height', 'filterLabel', 'legendLabel', 'xLabel', 'yLabel', 'zLabel', 'xValueLabel', 'yValueLabel', 'zValueLabel', 'showXAxis', 'showYAxis', 'showZAxis', 'showGrid', 'showPerspective', 'showShadow', 'keepAspectRatio', 'verticalRatio', 'dotSizeRatio', 'dotSizeMinFraction', 'dotSizeMaxFraction', 'showAnimationControls', 'animationInterval', 'animationPreload', 'animationAutoStart', 'axisColor', 'gridColor', 'xCenter', 'yCenter', 'zoomable', 'ctrlToZoom'];
|
16430 |
|
16431 |
|
16432 |
|
16433 |
|
16434 |
|
16435 |
|
16436 |
|
16437 | var PREFIXEDOPTIONKEYS = ['xBarWidth', 'yBarWidth', 'valueMin', 'valueMax', 'xMin', 'xMax', 'xStep', 'yMin', 'yMax', 'yStep', 'zMin', 'zMax', 'zStep'];
|
16438 |
|
16439 | var DEFAULTS = undefined;
|
16440 |
|
16441 |
|
16442 |
|
16443 |
|
16444 |
|
16445 |
|
16446 |
|
16447 |
|
16448 |
|
16449 | function isEmpty(obj) {
|
16450 | for (var prop in obj) {
|
16451 | if (obj.hasOwnProperty(prop)) return false;
|
16452 | }
|
16453 |
|
16454 | return true;
|
16455 | }
|
16456 |
|
16457 |
|
16458 |
|
16459 |
|
16460 |
|
16461 |
|
16462 |
|
16463 |
|
16464 |
|
16465 |
|
16466 | function capitalize(str) {
|
16467 | if (str === undefined || str === "" || typeof str != "string") {
|
16468 | return str;
|
16469 | }
|
16470 |
|
16471 | return str.charAt(0).toUpperCase() + str.slice(1);
|
16472 | }
|
16473 |
|
16474 |
|
16475 |
|
16476 |
|
16477 |
|
16478 |
|
16479 |
|
16480 |
|
16481 |
|
16482 | function prefixFieldName(prefix, fieldName) {
|
16483 | if (prefix === undefined || prefix === "") {
|
16484 | return fieldName;
|
16485 | }
|
16486 |
|
16487 | return prefix + capitalize(fieldName);
|
16488 | }
|
16489 |
|
16490 |
|
16491 |
|
16492 |
|
16493 |
|
16494 |
|
16495 |
|
16496 |
|
16497 |
|
16498 |
|
16499 |
|
16500 |
|
16501 |
|
16502 |
|
16503 |
|
16504 |
|
16505 |
|
16506 |
|
16507 | function forceCopy(src, dst, fields, prefix) {
|
16508 | var srcKey;
|
16509 | var dstKey;
|
16510 |
|
16511 | for (var i = 0; i < fields.length; ++i) {
|
16512 | srcKey = fields[i];
|
16513 | dstKey = prefixFieldName(prefix, srcKey);
|
16514 | dst[dstKey] = src[srcKey];
|
16515 | }
|
16516 | }
|
16517 |
|
16518 |
|
16519 |
|
16520 |
|
16521 |
|
16522 |
|
16523 |
|
16524 |
|
16525 |
|
16526 |
|
16527 |
|
16528 |
|
16529 |
|
16530 | function safeCopy(src, dst, fields, prefix) {
|
16531 | var srcKey;
|
16532 | var dstKey;
|
16533 |
|
16534 | for (var i = 0; i < fields.length; ++i) {
|
16535 | srcKey = fields[i];
|
16536 | if (src[srcKey] === undefined) continue;
|
16537 | dstKey = prefixFieldName(prefix, srcKey);
|
16538 | dst[dstKey] = src[srcKey];
|
16539 | }
|
16540 | }
|
16541 |
|
16542 |
|
16543 |
|
16544 |
|
16545 |
|
16546 |
|
16547 |
|
16548 |
|
16549 |
|
16550 |
|
16551 |
|
16552 |
|
16553 |
|
16554 | function setDefaults(src, dst) {
|
16555 | if (src === undefined || isEmpty(src)) {
|
16556 | throw new Error('No DEFAULTS passed');
|
16557 | }
|
16558 |
|
16559 | if (dst === undefined) {
|
16560 | throw new Error('No dst passed');
|
16561 | }
|
16562 |
|
16563 |
|
16564 | DEFAULTS = src;
|
16565 |
|
16566 | forceCopy(src, dst, OPTIONKEYS);
|
16567 | forceCopy(src, dst, PREFIXEDOPTIONKEYS, 'default');
|
16568 |
|
16569 | setSpecialSettings(src, dst);
|
16570 |
|
16571 | dst.margin = 10;
|
16572 |
|
16573 | dst.showGrayBottom = false;
|
16574 |
|
16575 | dst.showTooltip = false;
|
16576 | dst.onclick_callback = null;
|
16577 | dst.eye = new Point3d_1(0, 0, -1);
|
16578 | }
|
16579 |
|
16580 |
|
16581 |
|
16582 |
|
16583 |
|
16584 |
|
16585 |
|
16586 | function setOptions(options, dst) {
|
16587 | if (options === undefined) {
|
16588 | return;
|
16589 | }
|
16590 |
|
16591 | if (dst === undefined) {
|
16592 | throw new Error('No dst passed');
|
16593 | }
|
16594 |
|
16595 | if (DEFAULTS === undefined || isEmpty(DEFAULTS)) {
|
16596 | throw new Error('DEFAULTS not set for module Settings');
|
16597 | }
|
16598 |
|
16599 |
|
16600 | safeCopy(options, dst, OPTIONKEYS);
|
16601 | safeCopy(options, dst, PREFIXEDOPTIONKEYS, 'default');
|
16602 |
|
16603 | setSpecialSettings(options, dst);
|
16604 | }
|
16605 |
|
16606 |
|
16607 |
|
16608 |
|
16609 |
|
16610 |
|
16611 |
|
16612 |
|
16613 |
|
16614 |
|
16615 | function setSpecialSettings(src, dst) {
|
16616 | if (src.backgroundColor !== undefined) {
|
16617 | setBackgroundColor(src.backgroundColor, dst);
|
16618 | }
|
16619 |
|
16620 | setDataColor(src.dataColor, dst);
|
16621 | setStyle(src.style, dst);
|
16622 | setShowLegend(src.showLegend, dst);
|
16623 | setCameraPosition(src.cameraPosition, dst);
|
16624 |
|
16625 |
|
16626 | if (src.tooltip !== undefined) {
|
16627 | dst.showTooltip = src.tooltip;
|
16628 | }
|
16629 |
|
16630 | if (src.onclick != undefined) {
|
16631 | dst.onclick_callback = src.onclick;
|
16632 | }
|
16633 |
|
16634 | if (src.tooltipStyle !== undefined) {
|
16635 | util.selectiveDeepExtend(['tooltipStyle'], dst, src);
|
16636 | }
|
16637 | }
|
16638 |
|
16639 |
|
16640 |
|
16641 |
|
16642 |
|
16643 |
|
16644 |
|
16645 |
|
16646 |
|
16647 |
|
16648 |
|
16649 | function setShowLegend(showLegend, dst) {
|
16650 | if (showLegend === undefined) {
|
16651 |
|
16652 | var isAutoByDefault = DEFAULTS.showLegend === undefined;
|
16653 |
|
16654 | if (isAutoByDefault) {
|
16655 |
|
16656 | var isLegendGraphStyle = dst.style === STYLE.DOTCOLOR || dst.style === STYLE.DOTSIZE;
|
16657 | dst.showLegend = isLegendGraphStyle;
|
16658 | }
|
16659 | } else {
|
16660 | dst.showLegend = showLegend;
|
16661 | }
|
16662 | }
|
16663 |
|
16664 |
|
16665 |
|
16666 |
|
16667 |
|
16668 |
|
16669 |
|
16670 |
|
16671 | function getStyleNumberByName(styleName) {
|
16672 | var number = STYLENAME[styleName];
|
16673 |
|
16674 | if (number === undefined) {
|
16675 | return -1;
|
16676 | }
|
16677 |
|
16678 | return number;
|
16679 | }
|
16680 |
|
16681 |
|
16682 |
|
16683 |
|
16684 |
|
16685 |
|
16686 |
|
16687 |
|
16688 | function checkStyleNumber(style) {
|
16689 | var valid = false;
|
16690 |
|
16691 | for (var n in STYLE) {
|
16692 | if (STYLE[n] === style) {
|
16693 | valid = true;
|
16694 | break;
|
16695 | }
|
16696 | }
|
16697 |
|
16698 | return valid;
|
16699 | }
|
16700 |
|
16701 |
|
16702 |
|
16703 |
|
16704 |
|
16705 |
|
16706 |
|
16707 | function setStyle(style, dst) {
|
16708 | if (style === undefined) {
|
16709 | return;
|
16710 | }
|
16711 |
|
16712 | var styleNumber;
|
16713 |
|
16714 | if (typeof style === 'string') {
|
16715 | styleNumber = getStyleNumberByName(style);
|
16716 |
|
16717 | if (styleNumber === -1) {
|
16718 | throw new Error('Style \'' + style + '\' is invalid');
|
16719 | }
|
16720 | } else {
|
16721 |
|
16722 | if (!checkStyleNumber(style)) {
|
16723 | throw new Error('Style \'' + style + '\' is invalid');
|
16724 | }
|
16725 |
|
16726 | styleNumber = style;
|
16727 | }
|
16728 |
|
16729 | dst.style = styleNumber;
|
16730 | }
|
16731 |
|
16732 |
|
16733 |
|
16734 |
|
16735 |
|
16736 |
|
16737 |
|
16738 | function setBackgroundColor(backgroundColor, dst) {
|
16739 | var fill = 'white';
|
16740 | var stroke = 'gray';
|
16741 | var strokeWidth = 1;
|
16742 |
|
16743 | if (typeof backgroundColor === 'string') {
|
16744 | fill = backgroundColor;
|
16745 | stroke = 'none';
|
16746 | strokeWidth = 0;
|
16747 | } else if (_typeof$2(backgroundColor) === 'object') {
|
16748 | if (backgroundColor.fill !== undefined) fill = backgroundColor.fill;
|
16749 | if (backgroundColor.stroke !== undefined) stroke = backgroundColor.stroke;
|
16750 | if (backgroundColor.strokeWidth !== undefined) strokeWidth = backgroundColor.strokeWidth;
|
16751 | } else {
|
16752 | throw new Error('Unsupported type of backgroundColor');
|
16753 | }
|
16754 |
|
16755 | dst.frame.style.backgroundColor = fill;
|
16756 | dst.frame.style.borderColor = stroke;
|
16757 | dst.frame.style.borderWidth = strokeWidth + 'px';
|
16758 | dst.frame.style.borderStyle = 'solid';
|
16759 | }
|
16760 |
|
16761 |
|
16762 |
|
16763 |
|
16764 |
|
16765 |
|
16766 |
|
16767 | function setDataColor(dataColor, dst) {
|
16768 | if (dataColor === undefined) {
|
16769 | return;
|
16770 | }
|
16771 |
|
16772 | if (dst.dataColor === undefined) {
|
16773 | dst.dataColor = {};
|
16774 | }
|
16775 |
|
16776 | if (typeof dataColor === 'string') {
|
16777 | dst.dataColor.fill = dataColor;
|
16778 | dst.dataColor.stroke = dataColor;
|
16779 | } else {
|
16780 | if (dataColor.fill) {
|
16781 | dst.dataColor.fill = dataColor.fill;
|
16782 | }
|
16783 |
|
16784 | if (dataColor.stroke) {
|
16785 | dst.dataColor.stroke = dataColor.stroke;
|
16786 | }
|
16787 |
|
16788 | if (dataColor.strokeWidth !== undefined) {
|
16789 | dst.dataColor.strokeWidth = dataColor.strokeWidth;
|
16790 | }
|
16791 | }
|
16792 | }
|
16793 |
|
16794 |
|
16795 |
|
16796 |
|
16797 |
|
16798 |
|
16799 |
|
16800 | function setCameraPosition(cameraPosition, dst) {
|
16801 | var camPos = cameraPosition;
|
16802 |
|
16803 | if (camPos === undefined) {
|
16804 | return;
|
16805 | }
|
16806 |
|
16807 | if (dst.camera === undefined) {
|
16808 | dst.camera = new Camera_1();
|
16809 | }
|
16810 |
|
16811 | dst.camera.setArmRotation(camPos.horizontal, camPos.vertical);
|
16812 | dst.camera.setArmLength(camPos.distance);
|
16813 | }
|
16814 |
|
16815 | var STYLE_1 = STYLE;
|
16816 | var setDefaults_1 = setDefaults;
|
16817 | var setOptions_1 = setOptions;
|
16818 | var setCameraPosition_1 = setCameraPosition;
|
16819 | var Settings = {
|
16820 | STYLE: STYLE_1,
|
16821 | setDefaults: setDefaults_1,
|
16822 | setOptions: setOptions_1,
|
16823 | setCameraPosition: setCameraPosition_1
|
16824 | };
|
16825 |
|
16826 | var errorFound = false;
|
16827 | var allOptions;
|
16828 | var printStyle = 'background: #FFeeee; color: #dd0000';
|
16829 |
|
16830 |
|
16831 |
|
16832 |
|
16833 | var Validator =
|
16834 |
|
16835 | function () {
|
16836 | |
16837 |
|
16838 |
|
16839 | function Validator() {
|
16840 | _classCallCheck(this, Validator);
|
16841 | }
|
16842 | |
16843 |
|
16844 |
|
16845 |
|
16846 |
|
16847 |
|
16848 |
|
16849 |
|
16850 |
|
16851 |
|
16852 | _createClass(Validator, null, [{
|
16853 | key: "validate",
|
16854 | value: function validate(options, referenceOptions, subObject) {
|
16855 | errorFound = false;
|
16856 | allOptions = referenceOptions;
|
16857 | var usedOptions = referenceOptions;
|
16858 |
|
16859 | if (subObject !== undefined) {
|
16860 | usedOptions = referenceOptions[subObject];
|
16861 | }
|
16862 |
|
16863 | Validator.parse(options, usedOptions, []);
|
16864 | return errorFound;
|
16865 | }
|
16866 | |
16867 |
|
16868 |
|
16869 |
|
16870 |
|
16871 |
|
16872 |
|
16873 |
|
16874 | }, {
|
16875 | key: "parse",
|
16876 | value: function parse(options, referenceOptions, path) {
|
16877 | for (var option in options) {
|
16878 | if (options.hasOwnProperty(option)) {
|
16879 | Validator.check(option, options, referenceOptions, path);
|
16880 | }
|
16881 | }
|
16882 | }
|
16883 | |
16884 |
|
16885 |
|
16886 |
|
16887 |
|
16888 |
|
16889 |
|
16890 |
|
16891 |
|
16892 | }, {
|
16893 | key: "check",
|
16894 | value: function check(option, options, referenceOptions, path) {
|
16895 | if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) {
|
16896 | Validator.getSuggestion(option, referenceOptions, path);
|
16897 | return;
|
16898 | }
|
16899 |
|
16900 | var referenceOption = option;
|
16901 | var is_object = true;
|
16902 |
|
16903 | if (referenceOptions[option] === undefined && referenceOptions.__any__ !== undefined) {
|
16904 |
|
16905 |
|
16906 |
|
16907 |
|
16908 | referenceOption = '__any__';
|
16909 |
|
16910 |
|
16911 | is_object = Validator.getType(options[option]) === 'object';
|
16912 | }
|
16913 |
|
16914 | var refOptionObj = referenceOptions[referenceOption];
|
16915 |
|
16916 | if (is_object && refOptionObj.__type__ !== undefined) {
|
16917 | refOptionObj = refOptionObj.__type__;
|
16918 | }
|
16919 |
|
16920 | Validator.checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path);
|
16921 | }
|
16922 | |
16923 |
|
16924 |
|
16925 |
|
16926 |
|
16927 |
|
16928 |
|
16929 |
|
16930 |
|
16931 |
|
16932 |
|
16933 | }, {
|
16934 | key: "checkFields",
|
16935 | value: function checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) {
|
16936 | var log = function log(message) {
|
16937 | console.log('%c' + message + Validator.printLocation(path, option), printStyle);
|
16938 | };
|
16939 |
|
16940 | var optionType = Validator.getType(options[option]);
|
16941 | var refOptionType = refOptionObj[optionType];
|
16942 |
|
16943 | if (refOptionType !== undefined) {
|
16944 |
|
16945 | if (Validator.getType(refOptionType) === 'array' && refOptionType.indexOf(options[option]) === -1) {
|
16946 | log('Invalid option detected in "' + option + '".' + ' Allowed values are:' + Validator.print(refOptionType) + ' not "' + options[option] + '". ');
|
16947 | errorFound = true;
|
16948 | } else if (optionType === 'object' && referenceOption !== "__any__") {
|
16949 | path = util.copyAndExtendArray(path, option);
|
16950 | Validator.parse(options[option], referenceOptions[referenceOption], path);
|
16951 | }
|
16952 | } else if (refOptionObj['any'] === undefined) {
|
16953 |
|
16954 | log('Invalid type received for "' + option + '". Expected: ' + Validator.print(Object.keys(refOptionObj)) + '. Received [' + optionType + '] "' + options[option] + '"');
|
16955 | errorFound = true;
|
16956 | }
|
16957 | }
|
16958 | |
16959 |
|
16960 |
|
16961 |
|
16962 |
|
16963 |
|
16964 |
|
16965 | }, {
|
16966 | key: "getType",
|
16967 | value: function getType(object) {
|
16968 | var type = _typeof$2(object);
|
16969 |
|
16970 | if (type === 'object') {
|
16971 | if (object === null) {
|
16972 | return 'null';
|
16973 | }
|
16974 |
|
16975 | if (object instanceof Boolean) {
|
16976 | return 'boolean';
|
16977 | }
|
16978 |
|
16979 | if (object instanceof Number) {
|
16980 | return 'number';
|
16981 | }
|
16982 |
|
16983 | if (object instanceof String) {
|
16984 | return 'string';
|
16985 | }
|
16986 |
|
16987 | if (Array.isArray(object)) {
|
16988 | return 'array';
|
16989 | }
|
16990 |
|
16991 | if (object instanceof Date) {
|
16992 | return 'date';
|
16993 | }
|
16994 |
|
16995 | if (object.nodeType !== undefined) {
|
16996 | return 'dom';
|
16997 | }
|
16998 |
|
16999 | if (object._isAMomentObject === true) {
|
17000 | return 'moment';
|
17001 | }
|
17002 |
|
17003 | return 'object';
|
17004 | } else if (type === 'number') {
|
17005 | return 'number';
|
17006 | } else if (type === 'boolean') {
|
17007 | return 'boolean';
|
17008 | } else if (type === 'string') {
|
17009 | return 'string';
|
17010 | } else if (type === undefined) {
|
17011 | return 'undefined';
|
17012 | }
|
17013 |
|
17014 | return type;
|
17015 | }
|
17016 | |
17017 |
|
17018 |
|
17019 |
|
17020 |
|
17021 |
|
17022 |
|
17023 | }, {
|
17024 | key: "getSuggestion",
|
17025 | value: function getSuggestion(option, options, path) {
|
17026 | var localSearch = Validator.findInOptions(option, options, path, false);
|
17027 | var globalSearch = Validator.findInOptions(option, allOptions, [], true);
|
17028 | var localSearchThreshold = 8;
|
17029 | var globalSearchThreshold = 4;
|
17030 | var msg;
|
17031 |
|
17032 | if (localSearch.indexMatch !== undefined) {
|
17033 | msg = ' in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was incomplete? Did you mean: "' + localSearch.indexMatch + '"?\n\n';
|
17034 | } else if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) {
|
17035 | msg = ' in ' + Validator.printLocation(localSearch.path, option, '') + 'Perhaps it was misplaced? Matching option found at: ' + Validator.printLocation(globalSearch.path, globalSearch.closestMatch, '');
|
17036 | } else if (localSearch.distance <= localSearchThreshold) {
|
17037 | msg = '. Did you mean "' + localSearch.closestMatch + '"?' + Validator.printLocation(localSearch.path, option);
|
17038 | } else {
|
17039 | msg = '. Did you mean one of these: ' + Validator.print(Object.keys(options)) + Validator.printLocation(path, option);
|
17040 | }
|
17041 |
|
17042 | console.log('%cUnknown option detected: "' + option + '"' + msg, printStyle);
|
17043 | errorFound = true;
|
17044 | }
|
17045 | |
17046 |
|
17047 |
|
17048 |
|
17049 |
|
17050 |
|
17051 |
|
17052 |
|
17053 |
|
17054 |
|
17055 | }, {
|
17056 | key: "findInOptions",
|
17057 | value: function findInOptions(option, options, path) {
|
17058 | var recursive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
17059 | var min = 1e9;
|
17060 | var closestMatch = '';
|
17061 | var closestMatchPath = [];
|
17062 | var lowerCaseOption = option.toLowerCase();
|
17063 | var indexMatch = undefined;
|
17064 |
|
17065 | for (var op in options) {
|
17066 |
|
17067 | var distance = void 0;
|
17068 |
|
17069 | if (options[op].__type__ !== undefined && recursive === true) {
|
17070 | var result = Validator.findInOptions(option, options[op], util.copyAndExtendArray(path, op));
|
17071 |
|
17072 | if (min > result.distance) {
|
17073 | closestMatch = result.closestMatch;
|
17074 | closestMatchPath = result.path;
|
17075 | min = result.distance;
|
17076 | indexMatch = result.indexMatch;
|
17077 | }
|
17078 | } else {
|
17079 | if (op.toLowerCase().indexOf(lowerCaseOption) !== -1) {
|
17080 | indexMatch = op;
|
17081 | }
|
17082 |
|
17083 | distance = Validator.levenshteinDistance(option, op);
|
17084 |
|
17085 | if (min > distance) {
|
17086 | closestMatch = op;
|
17087 | closestMatchPath = util.copyArray(path);
|
17088 | min = distance;
|
17089 | }
|
17090 | }
|
17091 | }
|
17092 |
|
17093 | return {
|
17094 | closestMatch: closestMatch,
|
17095 | path: closestMatchPath,
|
17096 | distance: min,
|
17097 | indexMatch: indexMatch
|
17098 | };
|
17099 | }
|
17100 | |
17101 |
|
17102 |
|
17103 |
|
17104 |
|
17105 |
|
17106 |
|
17107 |
|
17108 | }, {
|
17109 | key: "printLocation",
|
17110 | value: function printLocation(path, option) {
|
17111 | var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Problem value found at: \n';
|
17112 | var str = '\n\n' + prefix + 'options = {\n';
|
17113 |
|
17114 | for (var i = 0; i < path.length; i++) {
|
17115 | for (var j = 0; j < i + 1; j++) {
|
17116 | str += ' ';
|
17117 | }
|
17118 |
|
17119 | str += path[i] + ': {\n';
|
17120 | }
|
17121 |
|
17122 | for (var _j = 0; _j < path.length + 1; _j++) {
|
17123 | str += ' ';
|
17124 | }
|
17125 |
|
17126 | str += option + '\n';
|
17127 |
|
17128 | for (var _i = 0; _i < path.length + 1; _i++) {
|
17129 | for (var _j2 = 0; _j2 < path.length - _i; _j2++) {
|
17130 | str += ' ';
|
17131 | }
|
17132 |
|
17133 | str += '}\n';
|
17134 | }
|
17135 |
|
17136 | return str + '\n\n';
|
17137 | }
|
17138 | |
17139 |
|
17140 |
|
17141 |
|
17142 |
|
17143 |
|
17144 | }, {
|
17145 | key: "print",
|
17146 | value: function print(options) {
|
17147 | return JSON.stringify(options).replace(/(\")|(\[)|(\])|(,"__type__")/g, "").replace(/(\,)/g, ', ');
|
17148 | }
|
17149 | |
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 |
|
17155 |
|
17156 |
|
17157 |
|
17158 |
|
17159 |
|
17160 |
|
17161 |
|
17162 |
|
17163 |
|
17164 |
|
17165 |
|
17166 |
|
17167 | }, {
|
17168 | key: "levenshteinDistance",
|
17169 | value: function levenshteinDistance(a, b) {
|
17170 | if (a.length === 0) return b.length;
|
17171 | if (b.length === 0) return a.length;
|
17172 | var matrix = [];
|
17173 |
|
17174 | var i;
|
17175 |
|
17176 | for (i = 0; i <= b.length; i++) {
|
17177 | matrix[i] = [i];
|
17178 | }
|
17179 |
|
17180 |
|
17181 | var j;
|
17182 |
|
17183 | for (j = 0; j <= a.length; j++) {
|
17184 | matrix[0][j] = j;
|
17185 | }
|
17186 |
|
17187 |
|
17188 | for (i = 1; i <= b.length; i++) {
|
17189 | for (j = 1; j <= a.length; j++) {
|
17190 | if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
17191 | matrix[i][j] = matrix[i - 1][j - 1];
|
17192 | } else {
|
17193 | matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1,
|
17194 | Math.min(matrix[i][j - 1] + 1,
|
17195 | matrix[i - 1][j] + 1));
|
17196 | }
|
17197 | }
|
17198 | }
|
17199 |
|
17200 | return matrix[b.length][a.length];
|
17201 | }
|
17202 | }]);
|
17203 |
|
17204 | return Validator;
|
17205 | }();
|
17206 |
|
17207 | var Validator$1 = Object.freeze({
|
17208 | Validator: Validator,
|
17209 | printStyle: printStyle
|
17210 | });
|
17211 |
|
17212 |
|
17213 |
|
17214 |
|
17215 |
|
17216 |
|
17217 |
|
17218 |
|
17219 | var string = 'string';
|
17220 | var bool = 'boolean';
|
17221 | var number = 'number';
|
17222 | var object = 'object';
|
17223 |
|
17224 |
|
17225 |
|
17226 |
|
17227 |
|
17228 | var colorOptions = {
|
17229 | fill: {
|
17230 | string: string
|
17231 | },
|
17232 | stroke: {
|
17233 | string: string
|
17234 | },
|
17235 | strokeWidth: {
|
17236 | number: number
|
17237 | },
|
17238 | __type__: {
|
17239 | string: string,
|
17240 | object: object,
|
17241 | 'undefined': 'undefined'
|
17242 | }
|
17243 | };
|
17244 |
|
17245 |
|
17246 |
|
17247 |
|
17248 |
|
17249 |
|
17250 |
|
17251 | var allOptions$1 = {
|
17252 | animationAutoStart: {
|
17253 | boolean: bool,
|
17254 | 'undefined': 'undefined'
|
17255 | },
|
17256 | animationInterval: {
|
17257 | number: number
|
17258 | },
|
17259 | animationPreload: {
|
17260 | boolean: bool
|
17261 | },
|
17262 | axisColor: {
|
17263 | string: string
|
17264 | },
|
17265 | backgroundColor: colorOptions,
|
17266 | xBarWidth: {
|
17267 | number: number,
|
17268 | 'undefined': 'undefined'
|
17269 | },
|
17270 | yBarWidth: {
|
17271 | number: number,
|
17272 | 'undefined': 'undefined'
|
17273 | },
|
17274 | cameraPosition: {
|
17275 | distance: {
|
17276 | number: number
|
17277 | },
|
17278 | horizontal: {
|
17279 | number: number
|
17280 | },
|
17281 | vertical: {
|
17282 | number: number
|
17283 | },
|
17284 | __type__: {
|
17285 | object: object
|
17286 | }
|
17287 | },
|
17288 | zoomable: {
|
17289 | boolean: bool
|
17290 | },
|
17291 | ctrlToZoom: {
|
17292 | boolean: bool
|
17293 | },
|
17294 | xCenter: {
|
17295 | string: string
|
17296 | },
|
17297 | yCenter: {
|
17298 | string: string
|
17299 | },
|
17300 | dataColor: colorOptions,
|
17301 | dotSizeMinFraction: {
|
17302 | number: number
|
17303 | },
|
17304 | dotSizeMaxFraction: {
|
17305 | number: number
|
17306 | },
|
17307 | dotSizeRatio: {
|
17308 | number: number
|
17309 | },
|
17310 | filterLabel: {
|
17311 | string: string
|
17312 | },
|
17313 | gridColor: {
|
17314 | string: string
|
17315 | },
|
17316 | onclick: {
|
17317 | 'function': 'function'
|
17318 | },
|
17319 | keepAspectRatio: {
|
17320 | boolean: bool
|
17321 | },
|
17322 | xLabel: {
|
17323 | string: string
|
17324 | },
|
17325 | yLabel: {
|
17326 | string: string
|
17327 | },
|
17328 | zLabel: {
|
17329 | string: string
|
17330 | },
|
17331 | legendLabel: {
|
17332 | string: string
|
17333 | },
|
17334 | xMin: {
|
17335 | number: number,
|
17336 | 'undefined': 'undefined'
|
17337 | },
|
17338 | yMin: {
|
17339 | number: number,
|
17340 | 'undefined': 'undefined'
|
17341 | },
|
17342 | zMin: {
|
17343 | number: number,
|
17344 | 'undefined': 'undefined'
|
17345 | },
|
17346 | xMax: {
|
17347 | number: number,
|
17348 | 'undefined': 'undefined'
|
17349 | },
|
17350 | yMax: {
|
17351 | number: number,
|
17352 | 'undefined': 'undefined'
|
17353 | },
|
17354 | zMax: {
|
17355 | number: number,
|
17356 | 'undefined': 'undefined'
|
17357 | },
|
17358 | showAnimationControls: {
|
17359 | boolean: bool,
|
17360 | 'undefined': 'undefined'
|
17361 | },
|
17362 | showGrid: {
|
17363 | boolean: bool
|
17364 | },
|
17365 | showLegend: {
|
17366 | boolean: bool,
|
17367 | 'undefined': 'undefined'
|
17368 | },
|
17369 | showPerspective: {
|
17370 | boolean: bool
|
17371 | },
|
17372 | showShadow: {
|
17373 | boolean: bool
|
17374 | },
|
17375 | showXAxis: {
|
17376 | boolean: bool
|
17377 | },
|
17378 | showYAxis: {
|
17379 | boolean: bool
|
17380 | },
|
17381 | showZAxis: {
|
17382 | boolean: bool
|
17383 | },
|
17384 | xStep: {
|
17385 | number: number,
|
17386 | 'undefined': 'undefined'
|
17387 | },
|
17388 | yStep: {
|
17389 | number: number,
|
17390 | 'undefined': 'undefined'
|
17391 | },
|
17392 | zStep: {
|
17393 | number: number,
|
17394 | 'undefined': 'undefined'
|
17395 | },
|
17396 | style: {
|
17397 | number: number,
|
17398 |
|
17399 | string: ['bar', 'bar-color', 'bar-size', 'dot', 'dot-line', 'dot-color', 'dot-size', 'line', 'grid', 'surface']
|
17400 | },
|
17401 | tooltip: {
|
17402 | boolean: bool,
|
17403 | 'function': 'function'
|
17404 | },
|
17405 | tooltipStyle: {
|
17406 | content: {
|
17407 | color: {
|
17408 | string: string
|
17409 | },
|
17410 | background: {
|
17411 | string: string
|
17412 | },
|
17413 | border: {
|
17414 | string: string
|
17415 | },
|
17416 | borderRadius: {
|
17417 | string: string
|
17418 | },
|
17419 | boxShadow: {
|
17420 | string: string
|
17421 | },
|
17422 | padding: {
|
17423 | string: string
|
17424 | },
|
17425 | __type__: {
|
17426 | object: object
|
17427 | }
|
17428 | },
|
17429 | line: {
|
17430 | borderLeft: {
|
17431 | string: string
|
17432 | },
|
17433 | height: {
|
17434 | string: string
|
17435 | },
|
17436 | width: {
|
17437 | string: string
|
17438 | },
|
17439 | pointerEvents: {
|
17440 | string: string
|
17441 | },
|
17442 | __type__: {
|
17443 | object: object
|
17444 | }
|
17445 | },
|
17446 | dot: {
|
17447 | border: {
|
17448 | string: string
|
17449 | },
|
17450 | borderRadius: {
|
17451 | string: string
|
17452 | },
|
17453 | height: {
|
17454 | string: string
|
17455 | },
|
17456 | width: {
|
17457 | string: string
|
17458 | },
|
17459 | pointerEvents: {
|
17460 | string: string
|
17461 | },
|
17462 | __type__: {
|
17463 | object: object
|
17464 | }
|
17465 | },
|
17466 | __type__: {
|
17467 | object: object
|
17468 | }
|
17469 | },
|
17470 | xValueLabel: {
|
17471 | 'function': 'function'
|
17472 | },
|
17473 | yValueLabel: {
|
17474 | 'function': 'function'
|
17475 | },
|
17476 | zValueLabel: {
|
17477 | 'function': 'function'
|
17478 | },
|
17479 | valueMax: {
|
17480 | number: number,
|
17481 | 'undefined': 'undefined'
|
17482 | },
|
17483 | valueMin: {
|
17484 | number: number,
|
17485 | 'undefined': 'undefined'
|
17486 | },
|
17487 | verticalRatio: {
|
17488 | number: number
|
17489 | },
|
17490 |
|
17491 | height: {
|
17492 | string: string
|
17493 | },
|
17494 | width: {
|
17495 | string: string
|
17496 | },
|
17497 | __type__: {
|
17498 | object: object
|
17499 | }
|
17500 | };
|
17501 |
|
17502 | var options = Object.freeze({
|
17503 | allOptions: allOptions$1
|
17504 | });
|
17505 |
|
17506 |
|
17507 |
|
17508 |
|
17509 |
|
17510 |
|
17511 |
|
17512 |
|
17513 |
|
17514 |
|
17515 | function Range() {
|
17516 | this.min = undefined;
|
17517 | this.max = undefined;
|
17518 | }
|
17519 |
|
17520 |
|
17521 |
|
17522 |
|
17523 |
|
17524 |
|
17525 |
|
17526 |
|
17527 |
|
17528 |
|
17529 | Range.prototype.adjust = function (value) {
|
17530 | if (value === undefined) return;
|
17531 |
|
17532 | if (this.min === undefined || this.min > value) {
|
17533 | this.min = value;
|
17534 | }
|
17535 |
|
17536 | if (this.max === undefined || this.max < value) {
|
17537 | this.max = value;
|
17538 | }
|
17539 | };
|
17540 |
|
17541 |
|
17542 |
|
17543 |
|
17544 |
|
17545 |
|
17546 |
|
17547 | Range.prototype.combine = function (range) {
|
17548 | this.add(range.min);
|
17549 | this.add(range.max);
|
17550 | };
|
17551 |
|
17552 |
|
17553 |
|
17554 |
|
17555 |
|
17556 |
|
17557 |
|
17558 |
|
17559 |
|
17560 |
|
17561 |
|
17562 |
|
17563 | Range.prototype.expand = function (val) {
|
17564 | if (val === undefined) {
|
17565 | return;
|
17566 | }
|
17567 |
|
17568 | var newMin = this.min - val;
|
17569 | var newMax = this.max + val;
|
17570 |
|
17571 |
|
17572 | if (newMin > newMax) {
|
17573 | throw new Error('Passed expansion value makes range invalid');
|
17574 | }
|
17575 |
|
17576 | this.min = newMin;
|
17577 | this.max = newMax;
|
17578 | };
|
17579 |
|
17580 |
|
17581 |
|
17582 |
|
17583 |
|
17584 |
|
17585 |
|
17586 | Range.prototype.range = function () {
|
17587 | return this.max - this.min;
|
17588 | };
|
17589 |
|
17590 |
|
17591 |
|
17592 |
|
17593 |
|
17594 |
|
17595 |
|
17596 | Range.prototype.center = function () {
|
17597 | return (this.min + this.max) / 2;
|
17598 | };
|
17599 |
|
17600 | var Range_1 = Range;
|
17601 |
|
17602 | var DataView$2 = visData.DataView;
|
17603 |
|
17604 |
|
17605 |
|
17606 |
|
17607 |
|
17608 |
|
17609 |
|
17610 |
|
17611 | function Filter(dataGroup, column, graph) {
|
17612 | this.dataGroup = dataGroup;
|
17613 | this.column = column;
|
17614 | this.graph = graph;
|
17615 |
|
17616 | this.index = undefined;
|
17617 | this.value = undefined;
|
17618 |
|
17619 | this.values = dataGroup.getDistinctValues(this.column);
|
17620 |
|
17621 | if (this.values.length > 0) {
|
17622 | this.selectValue(0);
|
17623 | }
|
17624 |
|
17625 |
|
17626 | this.dataPoints = [];
|
17627 | this.loaded = false;
|
17628 | this.onLoadCallback = undefined;
|
17629 |
|
17630 | if (graph.animationPreload) {
|
17631 | this.loaded = false;
|
17632 | this.loadInBackground();
|
17633 | } else {
|
17634 | this.loaded = true;
|
17635 | }
|
17636 | }
|
17637 |
|
17638 |
|
17639 |
|
17640 |
|
17641 |
|
17642 |
|
17643 | Filter.prototype.isLoaded = function () {
|
17644 | return this.loaded;
|
17645 | };
|
17646 |
|
17647 |
|
17648 |
|
17649 |
|
17650 |
|
17651 |
|
17652 | Filter.prototype.getLoadedProgress = function () {
|
17653 | var len = this.values.length;
|
17654 | var i = 0;
|
17655 |
|
17656 | while (this.dataPoints[i]) {
|
17657 | i++;
|
17658 | }
|
17659 |
|
17660 | return Math.round(i / len * 100);
|
17661 | };
|
17662 |
|
17663 |
|
17664 |
|
17665 |
|
17666 |
|
17667 |
|
17668 | Filter.prototype.getLabel = function () {
|
17669 | return this.graph.filterLabel;
|
17670 | };
|
17671 |
|
17672 |
|
17673 |
|
17674 |
|
17675 |
|
17676 |
|
17677 | Filter.prototype.getColumn = function () {
|
17678 | return this.column;
|
17679 | };
|
17680 |
|
17681 |
|
17682 |
|
17683 |
|
17684 |
|
17685 |
|
17686 | Filter.prototype.getSelectedValue = function () {
|
17687 | if (this.index === undefined) return undefined;
|
17688 | return this.values[this.index];
|
17689 | };
|
17690 |
|
17691 |
|
17692 |
|
17693 |
|
17694 |
|
17695 |
|
17696 | Filter.prototype.getValues = function () {
|
17697 | return this.values;
|
17698 | };
|
17699 |
|
17700 |
|
17701 |
|
17702 |
|
17703 |
|
17704 |
|
17705 |
|
17706 | Filter.prototype.getValue = function (index) {
|
17707 | if (index >= this.values.length) throw new Error('Index out of range');
|
17708 | return this.values[index];
|
17709 | };
|
17710 |
|
17711 |
|
17712 |
|
17713 |
|
17714 |
|
17715 |
|
17716 |
|
17717 | Filter.prototype._getDataPoints = function (index) {
|
17718 | if (index === undefined) index = this.index;
|
17719 | if (index === undefined) return [];
|
17720 | var dataPoints;
|
17721 |
|
17722 | if (this.dataPoints[index]) {
|
17723 | dataPoints = this.dataPoints[index];
|
17724 | } else {
|
17725 | var f = {};
|
17726 | f.column = this.column;
|
17727 | f.value = this.values[index];
|
17728 | var dataView = new DataView$2(this.dataGroup.getDataSet(), {
|
17729 | filter: function filter(item) {
|
17730 | return item[f.column] == f.value;
|
17731 | }
|
17732 | }).get();
|
17733 | dataPoints = this.dataGroup._getDataPoints(dataView);
|
17734 | this.dataPoints[index] = dataPoints;
|
17735 | }
|
17736 |
|
17737 | return dataPoints;
|
17738 | };
|
17739 |
|
17740 |
|
17741 |
|
17742 |
|
17743 |
|
17744 |
|
17745 |
|
17746 | Filter.prototype.setOnLoadCallback = function (callback) {
|
17747 | this.onLoadCallback = callback;
|
17748 | };
|
17749 |
|
17750 |
|
17751 |
|
17752 |
|
17753 |
|
17754 |
|
17755 |
|
17756 | Filter.prototype.selectValue = function (index) {
|
17757 | if (index >= this.values.length) throw new Error('Index out of range');
|
17758 | this.index = index;
|
17759 | this.value = this.values[index];
|
17760 | };
|
17761 |
|
17762 |
|
17763 |
|
17764 |
|
17765 |
|
17766 |
|
17767 |
|
17768 |
|
17769 | Filter.prototype.loadInBackground = function (index) {
|
17770 | if (index === undefined) index = 0;
|
17771 | var frame = this.graph.frame;
|
17772 |
|
17773 | if (index < this.values.length) {
|
17774 |
|
17775 | if (frame.progress === undefined) {
|
17776 | frame.progress = document.createElement('DIV');
|
17777 | frame.progress.style.position = 'absolute';
|
17778 | frame.progress.style.color = 'gray';
|
17779 | frame.appendChild(frame.progress);
|
17780 | }
|
17781 |
|
17782 | var progress = this.getLoadedProgress();
|
17783 | frame.progress.innerHTML = 'Loading animation... ' + progress + '%';
|
17784 |
|
17785 | frame.progress.style.bottom = 60 + 'px';
|
17786 |
|
17787 | frame.progress.style.left = 10 + 'px';
|
17788 | var me = this;
|
17789 | setTimeout(function () {
|
17790 | me.loadInBackground(index + 1);
|
17791 | }, 10);
|
17792 | this.loaded = false;
|
17793 | } else {
|
17794 | this.loaded = true;
|
17795 |
|
17796 | if (frame.progress !== undefined) {
|
17797 | frame.removeChild(frame.progress);
|
17798 | frame.progress = undefined;
|
17799 | }
|
17800 |
|
17801 | if (this.onLoadCallback) this.onLoadCallback();
|
17802 | }
|
17803 | };
|
17804 |
|
17805 | var Filter_1 = Filter;
|
17806 |
|
17807 | var DataSet$2 = visData.DataSet;
|
17808 | var DataView$3 = visData.DataView;
|
17809 |
|
17810 |
|
17811 |
|
17812 |
|
17813 |
|
17814 |
|
17815 |
|
17816 |
|
17817 |
|
17818 |
|
17819 |
|
17820 |
|
17821 |
|
17822 | function DataGroup() {
|
17823 | this.dataTable = null;
|
17824 | }
|
17825 |
|
17826 |
|
17827 |
|
17828 |
|
17829 |
|
17830 |
|
17831 |
|
17832 |
|
17833 |
|
17834 |
|
17835 |
|
17836 |
|
17837 |
|
17838 |
|
17839 |
|
17840 |
|
17841 |
|
17842 | DataGroup.prototype.initializeData = function (graph3d, rawData, style) {
|
17843 | if (rawData === undefined) return;
|
17844 |
|
17845 | if (Array.isArray(rawData)) {
|
17846 | rawData = new DataSet$2(rawData);
|
17847 | }
|
17848 |
|
17849 | var data;
|
17850 |
|
17851 | if (rawData instanceof DataSet$2 || rawData instanceof DataView$3) {
|
17852 | data = rawData.get();
|
17853 | } else {
|
17854 | throw new Error('Array, DataSet, or DataView expected');
|
17855 | }
|
17856 |
|
17857 | if (data.length == 0) return;
|
17858 | this.style = style;
|
17859 |
|
17860 | if (this.dataSet) {
|
17861 | this.dataSet.off('*', this._onChange);
|
17862 | }
|
17863 |
|
17864 | this.dataSet = rawData;
|
17865 | this.dataTable = data;
|
17866 |
|
17867 | var me = this;
|
17868 |
|
17869 | this._onChange = function () {
|
17870 | graph3d.setData(me.dataSet);
|
17871 | };
|
17872 |
|
17873 | this.dataSet.on('*', this._onChange);
|
17874 |
|
17875 | this.colX = 'x';
|
17876 | this.colY = 'y';
|
17877 | this.colZ = 'z';
|
17878 | var withBars = graph3d.hasBars(style);
|
17879 |
|
17880 | if (withBars) {
|
17881 | if (graph3d.defaultXBarWidth !== undefined) {
|
17882 | this.xBarWidth = graph3d.defaultXBarWidth;
|
17883 | } else {
|
17884 | this.xBarWidth = this.getSmallestDifference(data, this.colX) || 1;
|
17885 | }
|
17886 |
|
17887 | if (graph3d.defaultYBarWidth !== undefined) {
|
17888 | this.yBarWidth = graph3d.defaultYBarWidth;
|
17889 | } else {
|
17890 | this.yBarWidth = this.getSmallestDifference(data, this.colY) || 1;
|
17891 | }
|
17892 | }
|
17893 |
|
17894 |
|
17895 | this._initializeRange(data, this.colX, graph3d, withBars);
|
17896 |
|
17897 | this._initializeRange(data, this.colY, graph3d, withBars);
|
17898 |
|
17899 | this._initializeRange(data, this.colZ, graph3d, false);
|
17900 |
|
17901 | if (data[0].hasOwnProperty('style')) {
|
17902 | this.colValue = 'style';
|
17903 | var valueRange = this.getColumnRange(data, this.colValue);
|
17904 |
|
17905 | this._setRangeDefaults(valueRange, graph3d.defaultValueMin, graph3d.defaultValueMax);
|
17906 |
|
17907 | this.valueRange = valueRange;
|
17908 | }
|
17909 |
|
17910 |
|
17911 | var table = this.getDataTable();
|
17912 |
|
17913 | if (table[0].hasOwnProperty('filter')) {
|
17914 | if (this.dataFilter === undefined) {
|
17915 | this.dataFilter = new Filter_1(this, 'filter', graph3d);
|
17916 | this.dataFilter.setOnLoadCallback(function () {
|
17917 | graph3d.redraw();
|
17918 | });
|
17919 | }
|
17920 | }
|
17921 |
|
17922 | var dataPoints;
|
17923 |
|
17924 | if (this.dataFilter) {
|
17925 |
|
17926 | dataPoints = this.dataFilter._getDataPoints();
|
17927 | } else {
|
17928 |
|
17929 | dataPoints = this._getDataPoints(this.getDataTable());
|
17930 | }
|
17931 |
|
17932 | return dataPoints;
|
17933 | };
|
17934 |
|
17935 |
|
17936 |
|
17937 |
|
17938 |
|
17939 |
|
17940 |
|
17941 |
|
17942 |
|
17943 |
|
17944 |
|
17945 |
|
17946 |
|
17947 |
|
17948 |
|
17949 |
|
17950 |
|
17951 | DataGroup.prototype._collectRangeSettings = function (column, graph3d) {
|
17952 | var index = ['x', 'y', 'z'].indexOf(column);
|
17953 |
|
17954 | if (index == -1) {
|
17955 | throw new Error('Column \'' + column + '\' invalid');
|
17956 | }
|
17957 |
|
17958 | var upper = column.toUpperCase();
|
17959 | return {
|
17960 | barWidth: this[column + 'BarWidth'],
|
17961 | min: graph3d['default' + upper + 'Min'],
|
17962 | max: graph3d['default' + upper + 'Max'],
|
17963 | step: graph3d['default' + upper + 'Step'],
|
17964 | range_label: column + 'Range',
|
17965 |
|
17966 | step_label: column + 'Step'
|
17967 |
|
17968 | };
|
17969 | };
|
17970 |
|
17971 |
|
17972 |
|
17973 |
|
17974 |
|
17975 |
|
17976 |
|
17977 |
|
17978 |
|
17979 |
|
17980 |
|
17981 |
|
17982 |
|
17983 |
|
17984 |
|
17985 | DataGroup.prototype._initializeRange = function (data, column, graph3d, withBars) {
|
17986 | var NUMSTEPS = 5;
|
17987 |
|
17988 | var settings = this._collectRangeSettings(column, graph3d);
|
17989 |
|
17990 | var range = this.getColumnRange(data, column);
|
17991 |
|
17992 | if (withBars && column != 'z') {
|
17993 |
|
17994 | range.expand(settings.barWidth / 2);
|
17995 | }
|
17996 |
|
17997 | this._setRangeDefaults(range, settings.min, settings.max);
|
17998 |
|
17999 | this[settings.range_label] = range;
|
18000 | this[settings.step_label] = settings.step !== undefined ? settings.step : range.range() / NUMSTEPS;
|
18001 | };
|
18002 |
|
18003 |
|
18004 |
|
18005 |
|
18006 |
|
18007 |
|
18008 |
|
18009 |
|
18010 |
|
18011 |
|
18012 |
|
18013 |
|
18014 | DataGroup.prototype.getDistinctValues = function (column, data) {
|
18015 | if (data === undefined) {
|
18016 | data = this.dataTable;
|
18017 | }
|
18018 |
|
18019 | var values = [];
|
18020 |
|
18021 | for (var i = 0; i < data.length; i++) {
|
18022 | var value = data[i][column] || 0;
|
18023 |
|
18024 | if (values.indexOf(value) === -1) {
|
18025 | values.push(value);
|
18026 | }
|
18027 | }
|
18028 |
|
18029 | return values.sort(function (a, b) {
|
18030 | return a - b;
|
18031 | });
|
18032 | };
|
18033 |
|
18034 |
|
18035 |
|
18036 |
|
18037 |
|
18038 |
|
18039 |
|
18040 |
|
18041 |
|
18042 |
|
18043 |
|
18044 |
|
18045 | DataGroup.prototype.getSmallestDifference = function (data, column) {
|
18046 | var values = this.getDistinctValues(data, column);
|
18047 |
|
18048 |
|
18049 | var smallest_diff = null;
|
18050 |
|
18051 | for (var i = 1; i < values.length; i++) {
|
18052 | var diff = values[i] - values[i - 1];
|
18053 |
|
18054 | if (smallest_diff == null || smallest_diff > diff) {
|
18055 | smallest_diff = diff;
|
18056 | }
|
18057 | }
|
18058 |
|
18059 | return smallest_diff;
|
18060 | };
|
18061 |
|
18062 |
|
18063 |
|
18064 |
|
18065 |
|
18066 |
|
18067 |
|
18068 |
|
18069 |
|
18070 |
|
18071 | DataGroup.prototype.getColumnRange = function (data, column) {
|
18072 | var range = new Range_1();
|
18073 |
|
18074 | for (var i = 0; i < data.length; i++) {
|
18075 | var item = data[i][column];
|
18076 | range.adjust(item);
|
18077 | }
|
18078 |
|
18079 | return range;
|
18080 | };
|
18081 |
|
18082 |
|
18083 |
|
18084 |
|
18085 |
|
18086 |
|
18087 |
|
18088 | DataGroup.prototype.getNumberOfRows = function () {
|
18089 | return this.dataTable.length;
|
18090 | };
|
18091 |
|
18092 |
|
18093 |
|
18094 |
|
18095 |
|
18096 |
|
18097 |
|
18098 |
|
18099 |
|
18100 |
|
18101 |
|
18102 |
|
18103 |
|
18104 |
|
18105 |
|
18106 |
|
18107 | DataGroup.prototype._setRangeDefaults = function (range, defaultMin, defaultMax) {
|
18108 | if (defaultMin !== undefined) {
|
18109 | range.min = defaultMin;
|
18110 | }
|
18111 |
|
18112 | if (defaultMax !== undefined) {
|
18113 | range.max = defaultMax;
|
18114 | }
|
18115 |
|
18116 |
|
18117 |
|
18118 |
|
18119 | if (range.max <= range.min) range.max = range.min + 1;
|
18120 | };
|
18121 |
|
18122 | DataGroup.prototype.getDataTable = function () {
|
18123 | return this.dataTable;
|
18124 | };
|
18125 |
|
18126 | DataGroup.prototype.getDataSet = function () {
|
18127 | return this.dataSet;
|
18128 | };
|
18129 |
|
18130 |
|
18131 |
|
18132 |
|
18133 |
|
18134 |
|
18135 |
|
18136 | DataGroup.prototype.getDataPoints = function (data) {
|
18137 | var dataPoints = [];
|
18138 |
|
18139 | for (var i = 0; i < data.length; i++) {
|
18140 | var point = new Point3d_1();
|
18141 | point.x = data[i][this.colX] || 0;
|
18142 | point.y = data[i][this.colY] || 0;
|
18143 | point.z = data[i][this.colZ] || 0;
|
18144 | point.data = data[i];
|
18145 |
|
18146 | if (this.colValue !== undefined) {
|
18147 | point.value = data[i][this.colValue] || 0;
|
18148 | }
|
18149 |
|
18150 | var obj = {};
|
18151 | obj.point = point;
|
18152 | obj.bottom = new Point3d_1(point.x, point.y, this.zRange.min);
|
18153 | obj.trans = undefined;
|
18154 | obj.screen = undefined;
|
18155 | dataPoints.push(obj);
|
18156 | }
|
18157 |
|
18158 | return dataPoints;
|
18159 | };
|
18160 |
|
18161 |
|
18162 |
|
18163 |
|
18164 |
|
18165 |
|
18166 |
|
18167 |
|
18168 |
|
18169 |
|
18170 | DataGroup.prototype.initDataAsMatrix = function (data) {
|
18171 |
|
18172 |
|
18173 | var x, y, i, obj;
|
18174 |
|
18175 | var dataX = this.getDistinctValues(this.colX, data);
|
18176 | var dataY = this.getDistinctValues(this.colY, data);
|
18177 | var dataPoints = this.getDataPoints(data);
|
18178 |
|
18179 | var dataMatrix = [];
|
18180 |
|
18181 | for (i = 0; i < dataPoints.length; i++) {
|
18182 | obj = dataPoints[i];
|
18183 |
|
18184 | var xIndex = dataX.indexOf(obj.point.x);
|
18185 | var yIndex = dataY.indexOf(obj.point.y);
|
18186 |
|
18187 | if (dataMatrix[xIndex] === undefined) {
|
18188 | dataMatrix[xIndex] = [];
|
18189 | }
|
18190 |
|
18191 | dataMatrix[xIndex][yIndex] = obj;
|
18192 | }
|
18193 |
|
18194 |
|
18195 | for (x = 0; x < dataMatrix.length; x++) {
|
18196 | for (y = 0; y < dataMatrix[x].length; y++) {
|
18197 | if (dataMatrix[x][y]) {
|
18198 | dataMatrix[x][y].pointRight = x < dataMatrix.length - 1 ? dataMatrix[x + 1][y] : undefined;
|
18199 | dataMatrix[x][y].pointTop = y < dataMatrix[x].length - 1 ? dataMatrix[x][y + 1] : undefined;
|
18200 | dataMatrix[x][y].pointCross = x < dataMatrix.length - 1 && y < dataMatrix[x].length - 1 ? dataMatrix[x + 1][y + 1] : undefined;
|
18201 | }
|
18202 | }
|
18203 | }
|
18204 |
|
18205 | return dataPoints;
|
18206 | };
|
18207 |
|
18208 |
|
18209 |
|
18210 |
|
18211 |
|
18212 |
|
18213 |
|
18214 | DataGroup.prototype.getInfo = function () {
|
18215 | var dataFilter = this.dataFilter;
|
18216 | if (!dataFilter) return undefined;
|
18217 | return dataFilter.getLabel() + ': ' + dataFilter.getSelectedValue();
|
18218 | };
|
18219 |
|
18220 |
|
18221 |
|
18222 |
|
18223 |
|
18224 | DataGroup.prototype.reload = function () {
|
18225 | if (this.dataTable) {
|
18226 | this.setData(this.dataTable);
|
18227 | }
|
18228 | };
|
18229 |
|
18230 |
|
18231 |
|
18232 |
|
18233 |
|
18234 |
|
18235 |
|
18236 |
|
18237 |
|
18238 | DataGroup.prototype._getDataPoints = function (data) {
|
18239 | var dataPoints = [];
|
18240 |
|
18241 | if (this.style === Settings.STYLE.GRID || this.style === Settings.STYLE.SURFACE) {
|
18242 | dataPoints = this.initDataAsMatrix(data);
|
18243 | } else {
|
18244 |
|
18245 | this._checkValueField(data);
|
18246 |
|
18247 | dataPoints = this.getDataPoints(data);
|
18248 |
|
18249 | if (this.style === Settings.STYLE.LINE) {
|
18250 |
|
18251 | for (var i = 0; i < dataPoints.length; i++) {
|
18252 | if (i > 0) {
|
18253 | dataPoints[i - 1].pointNext = dataPoints[i];
|
18254 | }
|
18255 | }
|
18256 | }
|
18257 | }
|
18258 |
|
18259 | return dataPoints;
|
18260 | };
|
18261 |
|
18262 |
|
18263 |
|
18264 |
|
18265 |
|
18266 |
|
18267 |
|
18268 |
|
18269 |
|
18270 |
|
18271 | DataGroup.prototype._checkValueField = function (data) {
|
18272 | var hasValueField = this.style === Settings.STYLE.BARCOLOR || this.style === Settings.STYLE.BARSIZE || this.style === Settings.STYLE.DOTCOLOR || this.style === Settings.STYLE.DOTSIZE;
|
18273 |
|
18274 | if (!hasValueField) {
|
18275 | return;
|
18276 | }
|
18277 |
|
18278 |
|
18279 | if (this.colValue === undefined) {
|
18280 | throw new Error('Expected data to have ' + ' field \'style\' ' + ' for graph style \'' + this.style + '\'');
|
18281 | }
|
18282 |
|
18283 |
|
18284 |
|
18285 | if (data[0][this.colValue] === undefined) {
|
18286 | throw new Error('Expected data to have ' + ' field \'' + this.colValue + '\' ' + ' for graph style \'' + this.style + '\'');
|
18287 | }
|
18288 | };
|
18289 |
|
18290 | var DataGroup_1 = DataGroup;
|
18291 |
|
18292 | var Validator$2 = Validator$1.Validator;
|
18293 | var printStyle$1 = Validator$1.printStyle;
|
18294 | var allOptions$2 = options.allOptions;
|
18295 |
|
18296 | Graph3d.STYLE = Settings.STYLE;
|
18297 |
|
18298 |
|
18299 |
|
18300 |
|
18301 |
|
18302 |
|
18303 |
|
18304 |
|
18305 | var autoByDefault = undefined;
|
18306 |
|
18307 |
|
18308 |
|
18309 |
|
18310 |
|
18311 |
|
18312 |
|
18313 |
|
18314 |
|
18315 |
|
18316 | Graph3d.DEFAULTS = {
|
18317 | width: '400px',
|
18318 | height: '400px',
|
18319 | filterLabel: 'time',
|
18320 | legendLabel: 'value',
|
18321 | xLabel: 'x',
|
18322 | yLabel: 'y',
|
18323 | zLabel: 'z',
|
18324 | xValueLabel: function xValueLabel(v) {
|
18325 | return v;
|
18326 | },
|
18327 | yValueLabel: function yValueLabel(v) {
|
18328 | return v;
|
18329 | },
|
18330 | zValueLabel: function zValueLabel(v) {
|
18331 | return v;
|
18332 | },
|
18333 | showXAxis: true,
|
18334 | showYAxis: true,
|
18335 | showZAxis: true,
|
18336 | showGrid: true,
|
18337 | showPerspective: true,
|
18338 | showShadow: false,
|
18339 | keepAspectRatio: true,
|
18340 | verticalRatio: 0.5,
|
18341 |
|
18342 | dotSizeRatio: 0.02,
|
18343 |
|
18344 | dotSizeMinFraction: 0.5,
|
18345 |
|
18346 | dotSizeMaxFraction: 2.5,
|
18347 |
|
18348 | showAnimationControls: autoByDefault,
|
18349 | animationInterval: 1000,
|
18350 |
|
18351 | animationPreload: false,
|
18352 | animationAutoStart: autoByDefault,
|
18353 | axisColor: '#4D4D4D',
|
18354 | gridColor: '#D3D3D3',
|
18355 | xCenter: '55%',
|
18356 | yCenter: '50%',
|
18357 | style: Graph3d.STYLE.DOT,
|
18358 | tooltip: false,
|
18359 | tooltipStyle: {
|
18360 | content: {
|
18361 | padding: '10px',
|
18362 | border: '1px solid #4d4d4d',
|
18363 | color: '#1a1a1a',
|
18364 | background: 'rgba(255,255,255,0.7)',
|
18365 | borderRadius: '2px',
|
18366 | boxShadow: '5px 5px 10px rgba(128,128,128,0.5)'
|
18367 | },
|
18368 | line: {
|
18369 | height: '40px',
|
18370 | width: '0',
|
18371 | borderLeft: '1px solid #4d4d4d',
|
18372 | pointerEvents: 'none'
|
18373 | },
|
18374 | dot: {
|
18375 | height: '0',
|
18376 | width: '0',
|
18377 | border: '5px solid #4d4d4d',
|
18378 | borderRadius: '5px',
|
18379 | pointerEvents: 'none'
|
18380 | }
|
18381 | },
|
18382 | dataColor: {
|
18383 | fill: '#7DC1FF',
|
18384 | stroke: '#3267D2',
|
18385 | strokeWidth: 1
|
18386 |
|
18387 | },
|
18388 | cameraPosition: {
|
18389 | horizontal: 1.0,
|
18390 | vertical: 0.5,
|
18391 | distance: 1.7
|
18392 | },
|
18393 | zoomable: true,
|
18394 | ctrlToZoom: false,
|
18395 |
|
18396 | |
18397 |
|
18398 |
|
18399 | showLegend: autoByDefault,
|
18400 |
|
18401 | backgroundColor: autoByDefault,
|
18402 | xBarWidth: autoByDefault,
|
18403 | yBarWidth: autoByDefault,
|
18404 | valueMin: autoByDefault,
|
18405 | valueMax: autoByDefault,
|
18406 | xMin: autoByDefault,
|
18407 | xMax: autoByDefault,
|
18408 | xStep: autoByDefault,
|
18409 | yMin: autoByDefault,
|
18410 | yMax: autoByDefault,
|
18411 | yStep: autoByDefault,
|
18412 | zMin: autoByDefault,
|
18413 | zMax: autoByDefault,
|
18414 | zStep: autoByDefault
|
18415 | };
|
18416 |
|
18417 |
|
18418 |
|
18419 |
|
18420 |
|
18421 |
|
18422 |
|
18423 |
|
18424 |
|
18425 |
|
18426 |
|
18427 |
|
18428 |
|
18429 |
|
18430 |
|
18431 | function Graph3d(container, data, options) {
|
18432 | if (!(this instanceof Graph3d)) {
|
18433 | throw new SyntaxError('Constructor must be called with the new operator');
|
18434 | }
|
18435 |
|
18436 |
|
18437 | this.containerElement = container;
|
18438 | this.dataGroup = new DataGroup_1();
|
18439 | this.dataPoints = null;
|
18440 |
|
18441 |
|
18442 | this.create();
|
18443 | Settings.setDefaults(Graph3d.DEFAULTS, this);
|
18444 |
|
18445 | this.colX = undefined;
|
18446 | this.colY = undefined;
|
18447 | this.colZ = undefined;
|
18448 | this.colValue = undefined;
|
18449 |
|
18450 |
|
18451 | this.setOptions(options);
|
18452 |
|
18453 | this.setData(data);
|
18454 | }
|
18455 |
|
18456 |
|
18457 | emitterComponent(Graph3d.prototype);
|
18458 |
|
18459 |
|
18460 |
|
18461 |
|
18462 | Graph3d.prototype._setScale = function () {
|
18463 | this.scale = new Point3d_1(1 / this.xRange.range(), 1 / this.yRange.range(), 1 / this.zRange.range());
|
18464 |
|
18465 | if (this.keepAspectRatio) {
|
18466 | if (this.scale.x < this.scale.y) {
|
18467 |
|
18468 | this.scale.y = this.scale.x;
|
18469 | } else {
|
18470 |
|
18471 | this.scale.x = this.scale.y;
|
18472 | }
|
18473 | }
|
18474 |
|
18475 |
|
18476 | this.scale.z *= this.verticalRatio;
|
18477 |
|
18478 |
|
18479 | if (this.valueRange !== undefined) {
|
18480 | this.scale.value = 1 / this.valueRange.range();
|
18481 | }
|
18482 |
|
18483 |
|
18484 | var xCenter = this.xRange.center() * this.scale.x;
|
18485 | var yCenter = this.yRange.center() * this.scale.y;
|
18486 | var zCenter = this.zRange.center() * this.scale.z;
|
18487 | this.camera.setArmLocation(xCenter, yCenter, zCenter);
|
18488 | };
|
18489 |
|
18490 |
|
18491 |
|
18492 |
|
18493 |
|
18494 |
|
18495 |
|
18496 |
|
18497 |
|
18498 | Graph3d.prototype._convert3Dto2D = function (point3d) {
|
18499 | var translation = this._convertPointToTranslation(point3d);
|
18500 |
|
18501 | return this._convertTranslationToScreen(translation);
|
18502 | };
|
18503 |
|
18504 |
|
18505 |
|
18506 |
|
18507 |
|
18508 |
|
18509 |
|
18510 |
|
18511 |
|
18512 |
|
18513 |
|
18514 | Graph3d.prototype._convertPointToTranslation = function (point3d) {
|
18515 | var cameraLocation = this.camera.getCameraLocation(),
|
18516 | cameraRotation = this.camera.getCameraRotation(),
|
18517 | ax = point3d.x * this.scale.x,
|
18518 | ay = point3d.y * this.scale.y,
|
18519 | az = point3d.z * this.scale.z,
|
18520 | cx = cameraLocation.x,
|
18521 | cy = cameraLocation.y,
|
18522 | cz = cameraLocation.z,
|
18523 |
|
18524 | sinTx = Math.sin(cameraRotation.x),
|
18525 | cosTx = Math.cos(cameraRotation.x),
|
18526 | sinTy = Math.sin(cameraRotation.y),
|
18527 | cosTy = Math.cos(cameraRotation.y),
|
18528 | sinTz = Math.sin(cameraRotation.z),
|
18529 | cosTz = Math.cos(cameraRotation.z),
|
18530 |
|
18531 | dx = cosTy * (sinTz * (ay - cy) + cosTz * (ax - cx)) - sinTy * (az - cz),
|
18532 | dy = sinTx * (cosTy * (az - cz) + sinTy * (sinTz * (ay - cy) + cosTz * (ax - cx))) + cosTx * (cosTz * (ay - cy) - sinTz * (ax - cx)),
|
18533 | dz = cosTx * (cosTy * (az - cz) + sinTy * (sinTz * (ay - cy) + cosTz * (ax - cx))) - sinTx * (cosTz * (ay - cy) - sinTz * (ax - cx));
|
18534 | return new Point3d_1(dx, dy, dz);
|
18535 | };
|
18536 |
|
18537 |
|
18538 |
|
18539 |
|
18540 |
|
18541 |
|
18542 |
|
18543 |
|
18544 |
|
18545 |
|
18546 | Graph3d.prototype._convertTranslationToScreen = function (translation) {
|
18547 | var ex = this.eye.x,
|
18548 | ey = this.eye.y,
|
18549 | ez = this.eye.z,
|
18550 | dx = translation.x,
|
18551 | dy = translation.y,
|
18552 | dz = translation.z;
|
18553 |
|
18554 | var bx;
|
18555 | var by;
|
18556 |
|
18557 | if (this.showPerspective) {
|
18558 | bx = (dx - ex) * (ez / dz);
|
18559 | by = (dy - ey) * (ez / dz);
|
18560 | } else {
|
18561 | bx = dx * -(ez / this.camera.getArmLength());
|
18562 | by = dy * -(ez / this.camera.getArmLength());
|
18563 | }
|
18564 |
|
18565 |
|
18566 |
|
18567 | return new Point2d_1(this.currentXCenter + bx * this.frame.canvas.clientWidth, this.currentYCenter - by * this.frame.canvas.clientWidth);
|
18568 | };
|
18569 |
|
18570 |
|
18571 |
|
18572 |
|
18573 |
|
18574 |
|
18575 |
|
18576 |
|
18577 | Graph3d.prototype._calcTranslations = function (points) {
|
18578 | for (var i = 0; i < points.length; i++) {
|
18579 | var point = points[i];
|
18580 | point.trans = this._convertPointToTranslation(point.point);
|
18581 | point.screen = this._convertTranslationToScreen(point.trans);
|
18582 |
|
18583 | var transBottom = this._convertPointToTranslation(point.bottom);
|
18584 |
|
18585 | point.dist = this.showPerspective ? transBottom.length() : -transBottom.z;
|
18586 | }
|
18587 |
|
18588 |
|
18589 | var sortDepth = function sortDepth(a, b) {
|
18590 | return b.dist - a.dist;
|
18591 | };
|
18592 |
|
18593 | points.sort(sortDepth);
|
18594 | };
|
18595 |
|
18596 |
|
18597 |
|
18598 |
|
18599 |
|
18600 | Graph3d.prototype._initializeRanges = function () {
|
18601 |
|
18602 | var dg = this.dataGroup;
|
18603 | this.xRange = dg.xRange;
|
18604 | this.yRange = dg.yRange;
|
18605 | this.zRange = dg.zRange;
|
18606 | this.valueRange = dg.valueRange;
|
18607 |
|
18608 |
|
18609 | this.xStep = dg.xStep;
|
18610 | this.yStep = dg.yStep;
|
18611 | this.zStep = dg.zStep;
|
18612 | this.xBarWidth = dg.xBarWidth;
|
18613 | this.yBarWidth = dg.yBarWidth;
|
18614 | this.colX = dg.colX;
|
18615 | this.colY = dg.colY;
|
18616 | this.colZ = dg.colZ;
|
18617 | this.colValue = dg.colValue;
|
18618 |
|
18619 | this._setScale();
|
18620 | };
|
18621 |
|
18622 |
|
18623 |
|
18624 |
|
18625 |
|
18626 |
|
18627 |
|
18628 |
|
18629 | Graph3d.prototype.getDataPoints = function (data) {
|
18630 | var dataPoints = [];
|
18631 |
|
18632 | for (var i = 0; i < data.length; i++) {
|
18633 | var point = new Point3d_1();
|
18634 | point.x = data[i][this.colX] || 0;
|
18635 | point.y = data[i][this.colY] || 0;
|
18636 | point.z = data[i][this.colZ] || 0;
|
18637 | point.data = data[i];
|
18638 |
|
18639 | if (this.colValue !== undefined) {
|
18640 | point.value = data[i][this.colValue] || 0;
|
18641 | }
|
18642 |
|
18643 | var obj = {};
|
18644 | obj.point = point;
|
18645 | obj.bottom = new Point3d_1(point.x, point.y, this.zRange.min);
|
18646 | obj.trans = undefined;
|
18647 | obj.screen = undefined;
|
18648 | dataPoints.push(obj);
|
18649 | }
|
18650 |
|
18651 | return dataPoints;
|
18652 | };
|
18653 |
|
18654 |
|
18655 |
|
18656 |
|
18657 |
|
18658 |
|
18659 |
|
18660 |
|
18661 |
|
18662 | Graph3d.prototype._getDataPoints = function (data) {
|
18663 |
|
18664 |
|
18665 | var x, y, i, obj;
|
18666 | var dataPoints = [];
|
18667 |
|
18668 | if (this.style === Graph3d.STYLE.GRID || this.style === Graph3d.STYLE.SURFACE) {
|
18669 |
|
18670 |
|
18671 |
|
18672 | var dataX = this.dataGroup.getDistinctValues(this.colX, data);
|
18673 | var dataY = this.dataGroup.getDistinctValues(this.colY, data);
|
18674 | dataPoints = this.getDataPoints(data);
|
18675 |
|
18676 | var dataMatrix = [];
|
18677 |
|
18678 | for (i = 0; i < dataPoints.length; i++) {
|
18679 | obj = dataPoints[i];
|
18680 |
|
18681 | var xIndex = dataX.indexOf(obj.point.x);
|
18682 | var yIndex = dataY.indexOf(obj.point.y);
|
18683 |
|
18684 | if (dataMatrix[xIndex] === undefined) {
|
18685 | dataMatrix[xIndex] = [];
|
18686 | }
|
18687 |
|
18688 | dataMatrix[xIndex][yIndex] = obj;
|
18689 | }
|
18690 |
|
18691 |
|
18692 | for (x = 0; x < dataMatrix.length; x++) {
|
18693 | for (y = 0; y < dataMatrix[x].length; y++) {
|
18694 | if (dataMatrix[x][y]) {
|
18695 | dataMatrix[x][y].pointRight = x < dataMatrix.length - 1 ? dataMatrix[x + 1][y] : undefined;
|
18696 | dataMatrix[x][y].pointTop = y < dataMatrix[x].length - 1 ? dataMatrix[x][y + 1] : undefined;
|
18697 | dataMatrix[x][y].pointCross = x < dataMatrix.length - 1 && y < dataMatrix[x].length - 1 ? dataMatrix[x + 1][y + 1] : undefined;
|
18698 | }
|
18699 | }
|
18700 | }
|
18701 | } else {
|
18702 |
|
18703 | this._checkValueField(data);
|
18704 |
|
18705 | dataPoints = this.getDataPoints(data);
|
18706 |
|
18707 | if (this.style === Graph3d.STYLE.LINE) {
|
18708 |
|
18709 | for (i = 0; i < dataPoints.length; i++) {
|
18710 | if (i > 0) {
|
18711 | dataPoints[i - 1].pointNext = dataPoints[i];
|
18712 | }
|
18713 | }
|
18714 | }
|
18715 | }
|
18716 |
|
18717 | return dataPoints;
|
18718 | };
|
18719 |
|
18720 |
|
18721 |
|
18722 |
|
18723 |
|
18724 |
|
18725 |
|
18726 |
|
18727 |
|
18728 | Graph3d.prototype.create = function () {
|
18729 |
|
18730 | while (this.containerElement.hasChildNodes()) {
|
18731 | this.containerElement.removeChild(this.containerElement.firstChild);
|
18732 | }
|
18733 |
|
18734 | this.frame = document.createElement('div');
|
18735 | this.frame.style.position = 'relative';
|
18736 | this.frame.style.overflow = 'hidden';
|
18737 |
|
18738 | this.frame.canvas = document.createElement('canvas');
|
18739 | this.frame.canvas.style.position = 'relative';
|
18740 | this.frame.appendChild(this.frame.canvas);
|
18741 |
|
18742 | {
|
18743 | var noCanvas = document.createElement('DIV');
|
18744 | noCanvas.style.color = 'red';
|
18745 | noCanvas.style.fontWeight = 'bold';
|
18746 | noCanvas.style.padding = '10px';
|
18747 | noCanvas.innerHTML = 'Error: your browser does not support HTML canvas';
|
18748 | this.frame.canvas.appendChild(noCanvas);
|
18749 | }
|
18750 | this.frame.filter = document.createElement('div');
|
18751 | this.frame.filter.style.position = 'absolute';
|
18752 | this.frame.filter.style.bottom = '0px';
|
18753 | this.frame.filter.style.left = '0px';
|
18754 | this.frame.filter.style.width = '100%';
|
18755 | this.frame.appendChild(this.frame.filter);
|
18756 |
|
18757 | var me = this;
|
18758 |
|
18759 | var onmousedown = function onmousedown(event) {
|
18760 | me._onMouseDown(event);
|
18761 | };
|
18762 |
|
18763 | var ontouchstart = function ontouchstart(event) {
|
18764 | me._onTouchStart(event);
|
18765 | };
|
18766 |
|
18767 | var onmousewheel = function onmousewheel(event) {
|
18768 | me._onWheel(event);
|
18769 | };
|
18770 |
|
18771 | var ontooltip = function ontooltip(event) {
|
18772 | me._onTooltip(event);
|
18773 | };
|
18774 |
|
18775 | var onclick = function onclick(event) {
|
18776 | me._onClick(event);
|
18777 | };
|
18778 |
|
18779 |
|
18780 | util.addEventListener(this.frame.canvas, 'mousedown', onmousedown);
|
18781 | util.addEventListener(this.frame.canvas, 'touchstart', ontouchstart);
|
18782 | util.addEventListener(this.frame.canvas, 'mousewheel', onmousewheel);
|
18783 | util.addEventListener(this.frame.canvas, 'mousemove', ontooltip);
|
18784 | util.addEventListener(this.frame.canvas, 'click', onclick);
|
18785 |
|
18786 | this.containerElement.appendChild(this.frame);
|
18787 | };
|
18788 |
|
18789 |
|
18790 |
|
18791 |
|
18792 |
|
18793 |
|
18794 |
|
18795 |
|
18796 |
|
18797 | Graph3d.prototype._setSize = function (width, height) {
|
18798 | this.frame.style.width = width;
|
18799 | this.frame.style.height = height;
|
18800 |
|
18801 | this._resizeCanvas();
|
18802 | };
|
18803 |
|
18804 |
|
18805 |
|
18806 |
|
18807 |
|
18808 | Graph3d.prototype._resizeCanvas = function () {
|
18809 | this.frame.canvas.style.width = '100%';
|
18810 | this.frame.canvas.style.height = '100%';
|
18811 | this.frame.canvas.width = this.frame.canvas.clientWidth;
|
18812 | this.frame.canvas.height = this.frame.canvas.clientHeight;
|
18813 |
|
18814 | this.frame.filter.style.width = this.frame.canvas.clientWidth - 2 * 10 + 'px';
|
18815 | };
|
18816 |
|
18817 |
|
18818 |
|
18819 |
|
18820 |
|
18821 |
|
18822 | Graph3d.prototype.animationStart = function () {
|
18823 |
|
18824 | if (!this.animationAutoStart || !this.dataGroup.dataFilter) return;
|
18825 | if (!this.frame.filter || !this.frame.filter.slider) throw new Error('No animation available');
|
18826 | this.frame.filter.slider.play();
|
18827 | };
|
18828 |
|
18829 |
|
18830 |
|
18831 |
|
18832 |
|
18833 | Graph3d.prototype.animationStop = function () {
|
18834 | if (!this.frame.filter || !this.frame.filter.slider) return;
|
18835 | this.frame.filter.slider.stop();
|
18836 | };
|
18837 |
|
18838 |
|
18839 |
|
18840 |
|
18841 |
|
18842 |
|
18843 |
|
18844 |
|
18845 | Graph3d.prototype._resizeCenter = function () {
|
18846 |
|
18847 | if (this.xCenter.charAt(this.xCenter.length - 1) === '%') {
|
18848 | this.currentXCenter = parseFloat(this.xCenter) / 100 * this.frame.canvas.clientWidth;
|
18849 | } else {
|
18850 | this.currentXCenter = parseFloat(this.xCenter);
|
18851 | }
|
18852 |
|
18853 |
|
18854 | if (this.yCenter.charAt(this.yCenter.length - 1) === '%') {
|
18855 | this.currentYCenter = parseFloat(this.yCenter) / 100 * (this.frame.canvas.clientHeight - this.frame.filter.clientHeight);
|
18856 | } else {
|
18857 | this.currentYCenter = parseFloat(this.yCenter);
|
18858 | }
|
18859 | };
|
18860 |
|
18861 |
|
18862 |
|
18863 |
|
18864 |
|
18865 |
|
18866 |
|
18867 |
|
18868 | Graph3d.prototype.getCameraPosition = function () {
|
18869 | var pos = this.camera.getArmRotation();
|
18870 | pos.distance = this.camera.getArmLength();
|
18871 | return pos;
|
18872 | };
|
18873 |
|
18874 |
|
18875 |
|
18876 |
|
18877 |
|
18878 |
|
18879 |
|
18880 |
|
18881 | Graph3d.prototype._readData = function (data) {
|
18882 |
|
18883 | this.dataPoints = this.dataGroup.initializeData(this, data, this.style);
|
18884 |
|
18885 | this._initializeRanges();
|
18886 |
|
18887 | this._redrawFilter();
|
18888 | };
|
18889 |
|
18890 |
|
18891 |
|
18892 |
|
18893 |
|
18894 |
|
18895 |
|
18896 | Graph3d.prototype.setData = function (data) {
|
18897 | if (data === undefined || data === null) return;
|
18898 |
|
18899 | this._readData(data);
|
18900 |
|
18901 | this.redraw();
|
18902 | this.animationStart();
|
18903 | };
|
18904 |
|
18905 |
|
18906 |
|
18907 |
|
18908 |
|
18909 |
|
18910 |
|
18911 | Graph3d.prototype.setOptions = function (options) {
|
18912 | if (options === undefined) return;
|
18913 | var errorFound = Validator$2.validate(options, allOptions$2);
|
18914 |
|
18915 | if (errorFound === true) {
|
18916 | console.log('%cErrors have been found in the supplied options object.', printStyle$1);
|
18917 | }
|
18918 |
|
18919 | this.animationStop();
|
18920 | Settings.setOptions(options, this);
|
18921 | this.setPointDrawingMethod();
|
18922 |
|
18923 | this._setSize(this.width, this.height);
|
18924 |
|
18925 | this.setData(this.dataGroup.getDataTable());
|
18926 | this.animationStart();
|
18927 | };
|
18928 |
|
18929 |
|
18930 |
|
18931 |
|
18932 |
|
18933 | Graph3d.prototype.setPointDrawingMethod = function () {
|
18934 | var method = undefined;
|
18935 |
|
18936 | switch (this.style) {
|
18937 | case Graph3d.STYLE.BAR:
|
18938 | method = Graph3d.prototype._redrawBarGraphPoint;
|
18939 | break;
|
18940 |
|
18941 | case Graph3d.STYLE.BARCOLOR:
|
18942 | method = Graph3d.prototype._redrawBarColorGraphPoint;
|
18943 | break;
|
18944 |
|
18945 | case Graph3d.STYLE.BARSIZE:
|
18946 | method = Graph3d.prototype._redrawBarSizeGraphPoint;
|
18947 | break;
|
18948 |
|
18949 | case Graph3d.STYLE.DOT:
|
18950 | method = Graph3d.prototype._redrawDotGraphPoint;
|
18951 | break;
|
18952 |
|
18953 | case Graph3d.STYLE.DOTLINE:
|
18954 | method = Graph3d.prototype._redrawDotLineGraphPoint;
|
18955 | break;
|
18956 |
|
18957 | case Graph3d.STYLE.DOTCOLOR:
|
18958 | method = Graph3d.prototype._redrawDotColorGraphPoint;
|
18959 | break;
|
18960 |
|
18961 | case Graph3d.STYLE.DOTSIZE:
|
18962 | method = Graph3d.prototype._redrawDotSizeGraphPoint;
|
18963 | break;
|
18964 |
|
18965 | case Graph3d.STYLE.SURFACE:
|
18966 | method = Graph3d.prototype._redrawSurfaceGraphPoint;
|
18967 | break;
|
18968 |
|
18969 | case Graph3d.STYLE.GRID:
|
18970 | method = Graph3d.prototype._redrawGridGraphPoint;
|
18971 | break;
|
18972 |
|
18973 | case Graph3d.STYLE.LINE:
|
18974 | method = Graph3d.prototype._redrawLineGraphPoint;
|
18975 | break;
|
18976 |
|
18977 | default:
|
18978 | throw new Error('Can not determine point drawing method ' + 'for graph style \'' + this.style + '\'');
|
18979 | }
|
18980 |
|
18981 | this._pointDrawingMethod = method;
|
18982 | };
|
18983 |
|
18984 |
|
18985 |
|
18986 |
|
18987 |
|
18988 | Graph3d.prototype.redraw = function () {
|
18989 | if (this.dataPoints === undefined) {
|
18990 | throw new Error('Graph data not initialized');
|
18991 | }
|
18992 |
|
18993 | this._resizeCanvas();
|
18994 |
|
18995 | this._resizeCenter();
|
18996 |
|
18997 | this._redrawSlider();
|
18998 |
|
18999 | this._redrawClear();
|
19000 |
|
19001 | this._redrawAxis();
|
19002 |
|
19003 | this._redrawDataGraph();
|
19004 |
|
19005 | this._redrawInfo();
|
19006 |
|
19007 | this._redrawLegend();
|
19008 | };
|
19009 |
|
19010 |
|
19011 |
|
19012 |
|
19013 |
|
19014 |
|
19015 |
|
19016 |
|
19017 | Graph3d.prototype._getContext = function () {
|
19018 | var canvas = this.frame.canvas;
|
19019 | var ctx = canvas.getContext('2d');
|
19020 | ctx.lineJoin = 'round';
|
19021 | ctx.lineCap = 'round';
|
19022 | return ctx;
|
19023 | };
|
19024 |
|
19025 |
|
19026 |
|
19027 |
|
19028 |
|
19029 | Graph3d.prototype._redrawClear = function () {
|
19030 | var canvas = this.frame.canvas;
|
19031 | var ctx = canvas.getContext('2d');
|
19032 | ctx.clearRect(0, 0, canvas.width, canvas.height);
|
19033 | };
|
19034 |
|
19035 | Graph3d.prototype._dotSize = function () {
|
19036 | return this.frame.clientWidth * this.dotSizeRatio;
|
19037 | };
|
19038 |
|
19039 |
|
19040 |
|
19041 |
|
19042 |
|
19043 |
|
19044 |
|
19045 |
|
19046 | Graph3d.prototype._getLegendWidth = function () {
|
19047 | var width;
|
19048 |
|
19049 | if (this.style === Graph3d.STYLE.DOTSIZE) {
|
19050 | var dotSize = this._dotSize();
|
19051 |
|
19052 |
|
19053 | width = dotSize * this.dotSizeMaxFraction;
|
19054 | } else if (this.style === Graph3d.STYLE.BARSIZE) {
|
19055 | width = this.xBarWidth;
|
19056 | } else {
|
19057 | width = 20;
|
19058 | }
|
19059 |
|
19060 | return width;
|
19061 | };
|
19062 |
|
19063 |
|
19064 |
|
19065 |
|
19066 |
|
19067 | Graph3d.prototype._redrawLegend = function () {
|
19068 |
|
19069 | if (this.showLegend !== true) {
|
19070 | return;
|
19071 | }
|
19072 |
|
19073 |
|
19074 | if (this.style === Graph3d.STYLE.LINE || this.style === Graph3d.STYLE.BARSIZE
|
19075 | ) {
|
19076 | return;
|
19077 | }
|
19078 |
|
19079 |
|
19080 | var isSizeLegend = this.style === Graph3d.STYLE.BARSIZE || this.style === Graph3d.STYLE.DOTSIZE;
|
19081 |
|
19082 | var isValueLegend = this.style === Graph3d.STYLE.DOTSIZE || this.style === Graph3d.STYLE.DOTCOLOR || this.style === Graph3d.STYLE.BARCOLOR;
|
19083 | var height = Math.max(this.frame.clientHeight * 0.25, 100);
|
19084 | var top = this.margin;
|
19085 |
|
19086 | var width = this._getLegendWidth();
|
19087 |
|
19088 |
|
19089 | var right = this.frame.clientWidth - this.margin;
|
19090 | var left = right - width;
|
19091 | var bottom = top + height;
|
19092 |
|
19093 | var ctx = this._getContext();
|
19094 |
|
19095 | ctx.lineWidth = 1;
|
19096 | ctx.font = '14px arial';
|
19097 |
|
19098 | if (isSizeLegend === false) {
|
19099 |
|
19100 | var ymin = 0;
|
19101 | var ymax = height;
|
19102 |
|
19103 | var y;
|
19104 |
|
19105 | for (y = ymin; y < ymax; y++) {
|
19106 | var f = (y - ymin) / (ymax - ymin);
|
19107 | var hue = f * 240;
|
19108 |
|
19109 | var color = this._hsv2rgb(hue, 1, 1);
|
19110 |
|
19111 | ctx.strokeStyle = color;
|
19112 | ctx.beginPath();
|
19113 | ctx.moveTo(left, top + y);
|
19114 | ctx.lineTo(right, top + y);
|
19115 | ctx.stroke();
|
19116 | }
|
19117 |
|
19118 | ctx.strokeStyle = this.axisColor;
|
19119 | ctx.strokeRect(left, top, width, height);
|
19120 | } else {
|
19121 |
|
19122 | var widthMin;
|
19123 |
|
19124 | if (this.style === Graph3d.STYLE.DOTSIZE) {
|
19125 |
|
19126 | widthMin = width * (this.dotSizeMinFraction / this.dotSizeMaxFraction);
|
19127 | } else if (this.style === Graph3d.STYLE.BARSIZE) ;
|
19128 |
|
19129 | ctx.strokeStyle = this.axisColor;
|
19130 | ctx.fillStyle = this.dataColor.fill;
|
19131 | ctx.beginPath();
|
19132 | ctx.moveTo(left, top);
|
19133 | ctx.lineTo(right, top);
|
19134 | ctx.lineTo(left + widthMin, bottom);
|
19135 | ctx.lineTo(left, bottom);
|
19136 | ctx.closePath();
|
19137 | ctx.fill();
|
19138 | ctx.stroke();
|
19139 | }
|
19140 |
|
19141 |
|
19142 | var gridLineLen = 5;
|
19143 |
|
19144 | var legendMin = isValueLegend ? this.valueRange.min : this.zRange.min;
|
19145 | var legendMax = isValueLegend ? this.valueRange.max : this.zRange.max;
|
19146 | var step = new StepNumber_1(legendMin, legendMax, (legendMax - legendMin) / 5, true);
|
19147 | step.start(true);
|
19148 | var from;
|
19149 | var to;
|
19150 |
|
19151 | while (!step.end()) {
|
19152 | y = bottom - (step.getCurrent() - legendMin) / (legendMax - legendMin) * height;
|
19153 | from = new Point2d_1(left - gridLineLen, y);
|
19154 | to = new Point2d_1(left, y);
|
19155 |
|
19156 | this._line(ctx, from, to);
|
19157 |
|
19158 | ctx.textAlign = 'right';
|
19159 | ctx.textBaseline = 'middle';
|
19160 | ctx.fillStyle = this.axisColor;
|
19161 | ctx.fillText(step.getCurrent(), left - 2 * gridLineLen, y);
|
19162 | step.next();
|
19163 | }
|
19164 |
|
19165 | ctx.textAlign = 'right';
|
19166 | ctx.textBaseline = 'top';
|
19167 | var label = this.legendLabel;
|
19168 | ctx.fillText(label, right, bottom + this.margin);
|
19169 | };
|
19170 |
|
19171 |
|
19172 |
|
19173 |
|
19174 |
|
19175 | Graph3d.prototype._redrawFilter = function () {
|
19176 | var dataFilter = this.dataGroup.dataFilter;
|
19177 | var filter = this.frame.filter;
|
19178 | filter.innerHTML = '';
|
19179 |
|
19180 | if (!dataFilter) {
|
19181 | filter.slider = undefined;
|
19182 | return;
|
19183 | }
|
19184 |
|
19185 | var options = {
|
19186 | 'visible': this.showAnimationControls
|
19187 | };
|
19188 | var slider = new Slider_1(filter, options);
|
19189 | filter.slider = slider;
|
19190 |
|
19191 | filter.style.padding = '10px';
|
19192 |
|
19193 | slider.setValues(dataFilter.values);
|
19194 | slider.setPlayInterval(this.animationInterval);
|
19195 |
|
19196 | var me = this;
|
19197 |
|
19198 | var onchange = function onchange() {
|
19199 | var dataFilter = me.dataGroup.dataFilter;
|
19200 | var index = slider.getIndex();
|
19201 | dataFilter.selectValue(index);
|
19202 | me.dataPoints = dataFilter._getDataPoints();
|
19203 | me.redraw();
|
19204 | };
|
19205 |
|
19206 | slider.setOnChangeCallback(onchange);
|
19207 | };
|
19208 |
|
19209 |
|
19210 |
|
19211 |
|
19212 |
|
19213 | Graph3d.prototype._redrawSlider = function () {
|
19214 | if (this.frame.filter.slider !== undefined) {
|
19215 | this.frame.filter.slider.redraw();
|
19216 | }
|
19217 | };
|
19218 |
|
19219 |
|
19220 |
|
19221 |
|
19222 |
|
19223 | Graph3d.prototype._redrawInfo = function () {
|
19224 | var info = this.dataGroup.getInfo();
|
19225 | if (info === undefined) return;
|
19226 |
|
19227 | var ctx = this._getContext();
|
19228 |
|
19229 | ctx.font = '14px arial';
|
19230 |
|
19231 | ctx.lineStyle = 'gray';
|
19232 | ctx.fillStyle = 'gray';
|
19233 | ctx.textAlign = 'left';
|
19234 | ctx.textBaseline = 'top';
|
19235 | var x = this.margin;
|
19236 | var y = this.margin;
|
19237 | ctx.fillText(info, x, y);
|
19238 | };
|
19239 |
|
19240 |
|
19241 |
|
19242 |
|
19243 |
|
19244 |
|
19245 |
|
19246 |
|
19247 |
|
19248 |
|
19249 |
|
19250 |
|
19251 |
|
19252 | Graph3d.prototype._line = function (ctx, from, to, strokeStyle) {
|
19253 | if (strokeStyle !== undefined) {
|
19254 | ctx.strokeStyle = strokeStyle;
|
19255 | }
|
19256 |
|
19257 | ctx.beginPath();
|
19258 | ctx.moveTo(from.x, from.y);
|
19259 | ctx.lineTo(to.x, to.y);
|
19260 | ctx.stroke();
|
19261 | };
|
19262 |
|
19263 |
|
19264 |
|
19265 |
|
19266 |
|
19267 |
|
19268 |
|
19269 |
|
19270 |
|
19271 |
|
19272 | Graph3d.prototype.drawAxisLabelX = function (ctx, point3d, text, armAngle, yMargin) {
|
19273 | if (yMargin === undefined) {
|
19274 | yMargin = 0;
|
19275 | }
|
19276 |
|
19277 | var point2d = this._convert3Dto2D(point3d);
|
19278 |
|
19279 | if (Math.cos(armAngle * 2) > 0) {
|
19280 | ctx.textAlign = 'center';
|
19281 | ctx.textBaseline = 'top';
|
19282 | point2d.y += yMargin;
|
19283 | } else if (Math.sin(armAngle * 2) < 0) {
|
19284 | ctx.textAlign = 'right';
|
19285 | ctx.textBaseline = 'middle';
|
19286 | } else {
|
19287 | ctx.textAlign = 'left';
|
19288 | ctx.textBaseline = 'middle';
|
19289 | }
|
19290 |
|
19291 | ctx.fillStyle = this.axisColor;
|
19292 | ctx.fillText(text, point2d.x, point2d.y);
|
19293 | };
|
19294 |
|
19295 |
|
19296 |
|
19297 |
|
19298 |
|
19299 |
|
19300 |
|
19301 |
|
19302 |
|
19303 |
|
19304 | Graph3d.prototype.drawAxisLabelY = function (ctx, point3d, text, armAngle, yMargin) {
|
19305 | if (yMargin === undefined) {
|
19306 | yMargin = 0;
|
19307 | }
|
19308 |
|
19309 | var point2d = this._convert3Dto2D(point3d);
|
19310 |
|
19311 | if (Math.cos(armAngle * 2) < 0) {
|
19312 | ctx.textAlign = 'center';
|
19313 | ctx.textBaseline = 'top';
|
19314 | point2d.y += yMargin;
|
19315 | } else if (Math.sin(armAngle * 2) > 0) {
|
19316 | ctx.textAlign = 'right';
|
19317 | ctx.textBaseline = 'middle';
|
19318 | } else {
|
19319 | ctx.textAlign = 'left';
|
19320 | ctx.textBaseline = 'middle';
|
19321 | }
|
19322 |
|
19323 | ctx.fillStyle = this.axisColor;
|
19324 | ctx.fillText(text, point2d.x, point2d.y);
|
19325 | };
|
19326 |
|
19327 |
|
19328 |
|
19329 |
|
19330 |
|
19331 |
|
19332 |
|
19333 |
|
19334 |
|
19335 | Graph3d.prototype.drawAxisLabelZ = function (ctx, point3d, text, offset) {
|
19336 | if (offset === undefined) {
|
19337 | offset = 0;
|
19338 | }
|
19339 |
|
19340 | var point2d = this._convert3Dto2D(point3d);
|
19341 |
|
19342 | ctx.textAlign = 'right';
|
19343 | ctx.textBaseline = 'middle';
|
19344 | ctx.fillStyle = this.axisColor;
|
19345 | ctx.fillText(text, point2d.x - offset, point2d.y);
|
19346 | };
|
19347 |
|
19348 |
|
19349 |
|
19350 |
|
19351 |
|
19352 |
|
19353 |
|
19354 |
|
19355 |
|
19356 |
|
19357 |
|
19358 |
|
19359 |
|
19360 |
|
19361 |
|
19362 |
|
19363 | Graph3d.prototype._line3d = function (ctx, from, to, strokeStyle) {
|
19364 | var from2d = this._convert3Dto2D(from);
|
19365 |
|
19366 | var to2d = this._convert3Dto2D(to);
|
19367 |
|
19368 | this._line(ctx, from2d, to2d, strokeStyle);
|
19369 | };
|
19370 |
|
19371 |
|
19372 |
|
19373 |
|
19374 |
|
19375 | Graph3d.prototype._redrawAxis = function () {
|
19376 | var ctx = this._getContext(),
|
19377 | from,
|
19378 | to,
|
19379 | step,
|
19380 | prettyStep,
|
19381 | text,
|
19382 | xText,
|
19383 | yText,
|
19384 | zText,
|
19385 | offset,
|
19386 | xOffset,
|
19387 | yOffset;
|
19388 |
|
19389 |
|
19390 |
|
19391 | ctx.font = 24 / this.camera.getArmLength() + 'px arial';
|
19392 |
|
19393 | var gridLenX = 0.025 / this.scale.x;
|
19394 | var gridLenY = 0.025 / this.scale.y;
|
19395 | var textMargin = 5 / this.camera.getArmLength();
|
19396 |
|
19397 | var armAngle = this.camera.getArmRotation().horizontal;
|
19398 | var armVector = new Point2d_1(Math.cos(armAngle), Math.sin(armAngle));
|
19399 | var xRange = this.xRange;
|
19400 | var yRange = this.yRange;
|
19401 | var zRange = this.zRange;
|
19402 | var point3d;
|
19403 |
|
19404 | ctx.lineWidth = 1;
|
19405 | prettyStep = this.defaultXStep === undefined;
|
19406 | step = new StepNumber_1(xRange.min, xRange.max, this.xStep, prettyStep);
|
19407 | step.start(true);
|
19408 |
|
19409 | while (!step.end()) {
|
19410 | var x = step.getCurrent();
|
19411 |
|
19412 | if (this.showGrid) {
|
19413 | from = new Point3d_1(x, yRange.min, zRange.min);
|
19414 | to = new Point3d_1(x, yRange.max, zRange.min);
|
19415 |
|
19416 | this._line3d(ctx, from, to, this.gridColor);
|
19417 | } else if (this.showXAxis) {
|
19418 | from = new Point3d_1(x, yRange.min, zRange.min);
|
19419 | to = new Point3d_1(x, yRange.min + gridLenX, zRange.min);
|
19420 |
|
19421 | this._line3d(ctx, from, to, this.axisColor);
|
19422 |
|
19423 | from = new Point3d_1(x, yRange.max, zRange.min);
|
19424 | to = new Point3d_1(x, yRange.max - gridLenX, zRange.min);
|
19425 |
|
19426 | this._line3d(ctx, from, to, this.axisColor);
|
19427 | }
|
19428 |
|
19429 | if (this.showXAxis) {
|
19430 | yText = armVector.x > 0 ? yRange.min : yRange.max;
|
19431 | point3d = new Point3d_1(x, yText, zRange.min);
|
19432 | var msg = ' ' + this.xValueLabel(x) + ' ';
|
19433 | this.drawAxisLabelX(ctx, point3d, msg, armAngle, textMargin);
|
19434 | }
|
19435 |
|
19436 | step.next();
|
19437 | }
|
19438 |
|
19439 |
|
19440 | ctx.lineWidth = 1;
|
19441 | prettyStep = this.defaultYStep === undefined;
|
19442 | step = new StepNumber_1(yRange.min, yRange.max, this.yStep, prettyStep);
|
19443 | step.start(true);
|
19444 |
|
19445 | while (!step.end()) {
|
19446 | var y = step.getCurrent();
|
19447 |
|
19448 | if (this.showGrid) {
|
19449 | from = new Point3d_1(xRange.min, y, zRange.min);
|
19450 | to = new Point3d_1(xRange.max, y, zRange.min);
|
19451 |
|
19452 | this._line3d(ctx, from, to, this.gridColor);
|
19453 | } else if (this.showYAxis) {
|
19454 | from = new Point3d_1(xRange.min, y, zRange.min);
|
19455 | to = new Point3d_1(xRange.min + gridLenY, y, zRange.min);
|
19456 |
|
19457 | this._line3d(ctx, from, to, this.axisColor);
|
19458 |
|
19459 | from = new Point3d_1(xRange.max, y, zRange.min);
|
19460 | to = new Point3d_1(xRange.max - gridLenY, y, zRange.min);
|
19461 |
|
19462 | this._line3d(ctx, from, to, this.axisColor);
|
19463 | }
|
19464 |
|
19465 | if (this.showYAxis) {
|
19466 | xText = armVector.y > 0 ? xRange.min : xRange.max;
|
19467 | point3d = new Point3d_1(xText, y, zRange.min);
|
19468 |
|
19469 | var _msg = ' ' + this.yValueLabel(y) + ' ';
|
19470 |
|
19471 | this.drawAxisLabelY(ctx, point3d, _msg, armAngle, textMargin);
|
19472 | }
|
19473 |
|
19474 | step.next();
|
19475 | }
|
19476 |
|
19477 |
|
19478 | if (this.showZAxis) {
|
19479 | ctx.lineWidth = 1;
|
19480 | prettyStep = this.defaultZStep === undefined;
|
19481 | step = new StepNumber_1(zRange.min, zRange.max, this.zStep, prettyStep);
|
19482 | step.start(true);
|
19483 | xText = armVector.x > 0 ? xRange.min : xRange.max;
|
19484 | yText = armVector.y < 0 ? yRange.min : yRange.max;
|
19485 |
|
19486 | while (!step.end()) {
|
19487 | var z = step.getCurrent();
|
19488 |
|
19489 | var from3d = new Point3d_1(xText, yText, z);
|
19490 |
|
19491 | var from2d = this._convert3Dto2D(from3d);
|
19492 |
|
19493 | to = new Point2d_1(from2d.x - textMargin, from2d.y);
|
19494 |
|
19495 | this._line(ctx, from2d, to, this.axisColor);
|
19496 |
|
19497 | var _msg2 = this.zValueLabel(z) + ' ';
|
19498 |
|
19499 | this.drawAxisLabelZ(ctx, from3d, _msg2, 5);
|
19500 | step.next();
|
19501 | }
|
19502 |
|
19503 | ctx.lineWidth = 1;
|
19504 | from = new Point3d_1(xText, yText, zRange.min);
|
19505 | to = new Point3d_1(xText, yText, zRange.max);
|
19506 |
|
19507 | this._line3d(ctx, from, to, this.axisColor);
|
19508 | }
|
19509 |
|
19510 |
|
19511 | if (this.showXAxis) {
|
19512 | var xMin2d;
|
19513 | var xMax2d;
|
19514 | ctx.lineWidth = 1;
|
19515 |
|
19516 | xMin2d = new Point3d_1(xRange.min, yRange.min, zRange.min);
|
19517 | xMax2d = new Point3d_1(xRange.max, yRange.min, zRange.min);
|
19518 |
|
19519 | this._line3d(ctx, xMin2d, xMax2d, this.axisColor);
|
19520 |
|
19521 |
|
19522 | xMin2d = new Point3d_1(xRange.min, yRange.max, zRange.min);
|
19523 | xMax2d = new Point3d_1(xRange.max, yRange.max, zRange.min);
|
19524 |
|
19525 | this._line3d(ctx, xMin2d, xMax2d, this.axisColor);
|
19526 | }
|
19527 |
|
19528 |
|
19529 | if (this.showYAxis) {
|
19530 | ctx.lineWidth = 1;
|
19531 |
|
19532 | from = new Point3d_1(xRange.min, yRange.min, zRange.min);
|
19533 | to = new Point3d_1(xRange.min, yRange.max, zRange.min);
|
19534 |
|
19535 | this._line3d(ctx, from, to, this.axisColor);
|
19536 |
|
19537 |
|
19538 | from = new Point3d_1(xRange.max, yRange.min, zRange.min);
|
19539 | to = new Point3d_1(xRange.max, yRange.max, zRange.min);
|
19540 |
|
19541 | this._line3d(ctx, from, to, this.axisColor);
|
19542 | }
|
19543 |
|
19544 |
|
19545 | var xLabel = this.xLabel;
|
19546 |
|
19547 | if (xLabel.length > 0 && this.showXAxis) {
|
19548 | yOffset = 0.1 / this.scale.y;
|
19549 | xText = (xRange.max + 3 * xRange.min) / 4;
|
19550 | yText = armVector.x > 0 ? yRange.min - yOffset : yRange.max + yOffset;
|
19551 | text = new Point3d_1(xText, yText, zRange.min);
|
19552 | this.drawAxisLabelX(ctx, text, xLabel, armAngle);
|
19553 | }
|
19554 |
|
19555 |
|
19556 | var yLabel = this.yLabel;
|
19557 |
|
19558 | if (yLabel.length > 0 && this.showYAxis) {
|
19559 | xOffset = 0.1 / this.scale.x;
|
19560 | xText = armVector.y > 0 ? xRange.min - xOffset : xRange.max + xOffset;
|
19561 | yText = (yRange.max + 3 * yRange.min) / 4;
|
19562 | text = new Point3d_1(xText, yText, zRange.min);
|
19563 | this.drawAxisLabelY(ctx, text, yLabel, armAngle);
|
19564 | }
|
19565 |
|
19566 |
|
19567 | var zLabel = this.zLabel;
|
19568 |
|
19569 | if (zLabel.length > 0 && this.showZAxis) {
|
19570 | offset = 30;
|
19571 |
|
19572 | xText = armVector.x > 0 ? xRange.min : xRange.max;
|
19573 | yText = armVector.y < 0 ? yRange.min : yRange.max;
|
19574 | zText = (zRange.max + 3 * zRange.min) / 4;
|
19575 | text = new Point3d_1(xText, yText, zText);
|
19576 | this.drawAxisLabelZ(ctx, text, zLabel, offset);
|
19577 | }
|
19578 | };
|
19579 |
|
19580 |
|
19581 |
|
19582 |
|
19583 |
|
19584 |
|
19585 |
|
19586 |
|
19587 |
|
19588 |
|
19589 | Graph3d.prototype._hsv2rgb = function (H, S, V) {
|
19590 | var R, G, B, C, Hi, X;
|
19591 | C = V * S;
|
19592 | Hi = Math.floor(H / 60);
|
19593 |
|
19594 | X = C * (1 - Math.abs(H / 60 % 2 - 1));
|
19595 |
|
19596 | switch (Hi) {
|
19597 | case 0:
|
19598 | R = C;
|
19599 | G = X;
|
19600 | B = 0;
|
19601 | break;
|
19602 |
|
19603 | case 1:
|
19604 | R = X;
|
19605 | G = C;
|
19606 | B = 0;
|
19607 | break;
|
19608 |
|
19609 | case 2:
|
19610 | R = 0;
|
19611 | G = C;
|
19612 | B = X;
|
19613 | break;
|
19614 |
|
19615 | case 3:
|
19616 | R = 0;
|
19617 | G = X;
|
19618 | B = C;
|
19619 | break;
|
19620 |
|
19621 | case 4:
|
19622 | R = X;
|
19623 | G = 0;
|
19624 | B = C;
|
19625 | break;
|
19626 |
|
19627 | case 5:
|
19628 | R = C;
|
19629 | G = 0;
|
19630 | B = X;
|
19631 | break;
|
19632 |
|
19633 | default:
|
19634 | R = 0;
|
19635 | G = 0;
|
19636 | B = 0;
|
19637 | break;
|
19638 | }
|
19639 |
|
19640 | return 'RGB(' + parseInt(R * 255) + ',' + parseInt(G * 255) + ',' + parseInt(B * 255) + ')';
|
19641 | };
|
19642 |
|
19643 |
|
19644 |
|
19645 |
|
19646 |
|
19647 |
|
19648 |
|
19649 |
|
19650 | Graph3d.prototype._getStrokeWidth = function (point) {
|
19651 | if (point !== undefined) {
|
19652 | if (this.showPerspective) {
|
19653 | return 1 / -point.trans.z * this.dataColor.strokeWidth;
|
19654 | } else {
|
19655 | return -(this.eye.z / this.camera.getArmLength()) * this.dataColor.strokeWidth;
|
19656 | }
|
19657 | }
|
19658 |
|
19659 | return this.dataColor.strokeWidth;
|
19660 | };
|
19661 |
|
19662 |
|
19663 |
|
19664 |
|
19665 |
|
19666 |
|
19667 |
|
19668 |
|
19669 |
|
19670 |
|
19671 |
|
19672 |
|
19673 |
|
19674 |
|
19675 |
|
19676 |
|
19677 | Graph3d.prototype._redrawBar = function (ctx, point, xWidth, yWidth, color, borderColor) {
|
19678 | var surface;
|
19679 |
|
19680 | var me = this;
|
19681 | var point3d = point.point;
|
19682 | var zMin = this.zRange.min;
|
19683 | var top = [{
|
19684 | point: new Point3d_1(point3d.x - xWidth, point3d.y - yWidth, point3d.z)
|
19685 | }, {
|
19686 | point: new Point3d_1(point3d.x + xWidth, point3d.y - yWidth, point3d.z)
|
19687 | }, {
|
19688 | point: new Point3d_1(point3d.x + xWidth, point3d.y + yWidth, point3d.z)
|
19689 | }, {
|
19690 | point: new Point3d_1(point3d.x - xWidth, point3d.y + yWidth, point3d.z)
|
19691 | }];
|
19692 | var bottom = [{
|
19693 | point: new Point3d_1(point3d.x - xWidth, point3d.y - yWidth, zMin)
|
19694 | }, {
|
19695 | point: new Point3d_1(point3d.x + xWidth, point3d.y - yWidth, zMin)
|
19696 | }, {
|
19697 | point: new Point3d_1(point3d.x + xWidth, point3d.y + yWidth, zMin)
|
19698 | }, {
|
19699 | point: new Point3d_1(point3d.x - xWidth, point3d.y + yWidth, zMin)
|
19700 | }];
|
19701 |
|
19702 | top.forEach(function (obj) {
|
19703 | obj.screen = me._convert3Dto2D(obj.point);
|
19704 | });
|
19705 | bottom.forEach(function (obj) {
|
19706 | obj.screen = me._convert3Dto2D(obj.point);
|
19707 | });
|
19708 |
|
19709 | var surfaces = [{
|
19710 | corners: top,
|
19711 | center: Point3d_1.avg(bottom[0].point, bottom[2].point)
|
19712 | }, {
|
19713 | corners: [top[0], top[1], bottom[1], bottom[0]],
|
19714 | center: Point3d_1.avg(bottom[1].point, bottom[0].point)
|
19715 | }, {
|
19716 | corners: [top[1], top[2], bottom[2], bottom[1]],
|
19717 | center: Point3d_1.avg(bottom[2].point, bottom[1].point)
|
19718 | }, {
|
19719 | corners: [top[2], top[3], bottom[3], bottom[2]],
|
19720 | center: Point3d_1.avg(bottom[3].point, bottom[2].point)
|
19721 | }, {
|
19722 | corners: [top[3], top[0], bottom[0], bottom[3]],
|
19723 | center: Point3d_1.avg(bottom[0].point, bottom[3].point)
|
19724 | }];
|
19725 | point.surfaces = surfaces;
|
19726 |
|
19727 | for (var j = 0; j < surfaces.length; j++) {
|
19728 | surface = surfaces[j];
|
19729 |
|
19730 | var transCenter = this._convertPointToTranslation(surface.center);
|
19731 |
|
19732 | surface.dist = this.showPerspective ? transCenter.length() : -transCenter.z;
|
19733 |
|
19734 |
|
19735 | }
|
19736 |
|
19737 |
|
19738 | surfaces.sort(function (a, b) {
|
19739 | var diff = b.dist - a.dist;
|
19740 | if (diff) return diff;
|
19741 |
|
19742 | if (a.corners === top) return 1;
|
19743 | if (b.corners === top) return -1;
|
19744 |
|
19745 | return 0;
|
19746 | });
|
19747 |
|
19748 | ctx.lineWidth = this._getStrokeWidth(point);
|
19749 | ctx.strokeStyle = borderColor;
|
19750 | ctx.fillStyle = color;
|
19751 |
|
19752 | for (var _j = 2; _j < surfaces.length; _j++) {
|
19753 | surface = surfaces[_j];
|
19754 |
|
19755 | this._polygon(ctx, surface.corners);
|
19756 | }
|
19757 | };
|
19758 |
|
19759 |
|
19760 |
|
19761 |
|
19762 |
|
19763 |
|
19764 |
|
19765 |
|
19766 |
|
19767 |
|
19768 | Graph3d.prototype._polygon = function (ctx, points, fillStyle, strokeStyle) {
|
19769 | if (points.length < 2) {
|
19770 | return;
|
19771 | }
|
19772 |
|
19773 | if (fillStyle !== undefined) {
|
19774 | ctx.fillStyle = fillStyle;
|
19775 | }
|
19776 |
|
19777 | if (strokeStyle !== undefined) {
|
19778 | ctx.strokeStyle = strokeStyle;
|
19779 | }
|
19780 |
|
19781 | ctx.beginPath();
|
19782 | ctx.moveTo(points[0].screen.x, points[0].screen.y);
|
19783 |
|
19784 | for (var i = 1; i < points.length; ++i) {
|
19785 | var point = points[i];
|
19786 | ctx.lineTo(point.screen.x, point.screen.y);
|
19787 | }
|
19788 |
|
19789 | ctx.closePath();
|
19790 | ctx.fill();
|
19791 | ctx.stroke();
|
19792 | };
|
19793 |
|
19794 |
|
19795 |
|
19796 |
|
19797 |
|
19798 |
|
19799 |
|
19800 |
|
19801 |
|
19802 |
|
19803 | Graph3d.prototype._drawCircle = function (ctx, point, color, borderColor, size) {
|
19804 | var radius = this._calcRadius(point, size);
|
19805 |
|
19806 | ctx.lineWidth = this._getStrokeWidth(point);
|
19807 | ctx.strokeStyle = borderColor;
|
19808 | ctx.fillStyle = color;
|
19809 | ctx.beginPath();
|
19810 | ctx.arc(point.screen.x, point.screen.y, radius, 0, Math.PI * 2, true);
|
19811 | ctx.fill();
|
19812 | ctx.stroke();
|
19813 | };
|
19814 |
|
19815 |
|
19816 |
|
19817 |
|
19818 |
|
19819 |
|
19820 |
|
19821 |
|
19822 |
|
19823 | Graph3d.prototype._getColorsRegular = function (point) {
|
19824 |
|
19825 | var hue = (1 - (point.point.z - this.zRange.min) * this.scale.z / this.verticalRatio) * 240;
|
19826 |
|
19827 | var color = this._hsv2rgb(hue, 1, 1);
|
19828 |
|
19829 | var borderColor = this._hsv2rgb(hue, 1, 0.8);
|
19830 |
|
19831 | return {
|
19832 | fill: color,
|
19833 | border: borderColor
|
19834 | };
|
19835 | };
|
19836 |
|
19837 |
|
19838 |
|
19839 |
|
19840 |
|
19841 |
|
19842 |
|
19843 |
|
19844 |
|
19845 |
|
19846 |
|
19847 |
|
19848 |
|
19849 |
|
19850 | Graph3d.prototype._getColorsColor = function (point) {
|
19851 |
|
19852 | var color, borderColor;
|
19853 |
|
19854 | if (typeof point.point.value === "string") {
|
19855 | color = point.point.value;
|
19856 | borderColor = point.point.value;
|
19857 | } else {
|
19858 | var hue = (1 - (point.point.value - this.valueRange.min) * this.scale.value) * 240;
|
19859 | color = this._hsv2rgb(hue, 1, 1);
|
19860 | borderColor = this._hsv2rgb(hue, 1, 0.8);
|
19861 | }
|
19862 |
|
19863 | return {
|
19864 | fill: color,
|
19865 | border: borderColor
|
19866 | };
|
19867 | };
|
19868 |
|
19869 |
|
19870 |
|
19871 |
|
19872 |
|
19873 |
|
19874 |
|
19875 |
|
19876 |
|
19877 | Graph3d.prototype._getColorsSize = function () {
|
19878 | return {
|
19879 | fill: this.dataColor.fill,
|
19880 | border: this.dataColor.stroke
|
19881 | };
|
19882 | };
|
19883 |
|
19884 |
|
19885 |
|
19886 |
|
19887 |
|
19888 |
|
19889 |
|
19890 |
|
19891 |
|
19892 |
|
19893 |
|
19894 |
|
19895 | Graph3d.prototype._calcRadius = function (point, size) {
|
19896 | if (size === undefined) {
|
19897 | size = this._dotSize();
|
19898 | }
|
19899 |
|
19900 | var radius;
|
19901 |
|
19902 | if (this.showPerspective) {
|
19903 | radius = size / -point.trans.z;
|
19904 | } else {
|
19905 | radius = size * -(this.eye.z / this.camera.getArmLength());
|
19906 | }
|
19907 |
|
19908 | if (radius < 0) {
|
19909 | radius = 0;
|
19910 | }
|
19911 |
|
19912 | return radius;
|
19913 | };
|
19914 |
|
19915 |
|
19916 |
|
19917 |
|
19918 |
|
19919 |
|
19920 |
|
19921 |
|
19922 |
|
19923 |
|
19924 |
|
19925 |
|
19926 | Graph3d.prototype._redrawBarGraphPoint = function (ctx, point) {
|
19927 | var xWidth = this.xBarWidth / 2;
|
19928 | var yWidth = this.yBarWidth / 2;
|
19929 |
|
19930 | var colors = this._getColorsRegular(point);
|
19931 |
|
19932 | this._redrawBar(ctx, point, xWidth, yWidth, colors.fill, colors.border);
|
19933 | };
|
19934 |
|
19935 |
|
19936 |
|
19937 |
|
19938 |
|
19939 |
|
19940 |
|
19941 |
|
19942 |
|
19943 | Graph3d.prototype._redrawBarColorGraphPoint = function (ctx, point) {
|
19944 | var xWidth = this.xBarWidth / 2;
|
19945 | var yWidth = this.yBarWidth / 2;
|
19946 |
|
19947 | var colors = this._getColorsColor(point);
|
19948 |
|
19949 | this._redrawBar(ctx, point, xWidth, yWidth, colors.fill, colors.border);
|
19950 | };
|
19951 |
|
19952 |
|
19953 |
|
19954 |
|
19955 |
|
19956 |
|
19957 |
|
19958 |
|
19959 |
|
19960 | Graph3d.prototype._redrawBarSizeGraphPoint = function (ctx, point) {
|
19961 |
|
19962 | var fraction = (point.point.value - this.valueRange.min) / this.valueRange.range();
|
19963 | var xWidth = this.xBarWidth / 2 * (fraction * 0.8 + 0.2);
|
19964 | var yWidth = this.yBarWidth / 2 * (fraction * 0.8 + 0.2);
|
19965 |
|
19966 | var colors = this._getColorsSize();
|
19967 |
|
19968 | this._redrawBar(ctx, point, xWidth, yWidth, colors.fill, colors.border);
|
19969 | };
|
19970 |
|
19971 |
|
19972 |
|
19973 |
|
19974 |
|
19975 |
|
19976 |
|
19977 |
|
19978 |
|
19979 | Graph3d.prototype._redrawDotGraphPoint = function (ctx, point) {
|
19980 | var colors = this._getColorsRegular(point);
|
19981 |
|
19982 | this._drawCircle(ctx, point, colors.fill, colors.border);
|
19983 | };
|
19984 |
|
19985 |
|
19986 |
|
19987 |
|
19988 |
|
19989 |
|
19990 |
|
19991 |
|
19992 |
|
19993 | Graph3d.prototype._redrawDotLineGraphPoint = function (ctx, point) {
|
19994 |
|
19995 | var from = this._convert3Dto2D(point.bottom);
|
19996 |
|
19997 | ctx.lineWidth = 1;
|
19998 |
|
19999 | this._line(ctx, from, point.screen, this.gridColor);
|
20000 |
|
20001 | this._redrawDotGraphPoint(ctx, point);
|
20002 | };
|
20003 |
|
20004 |
|
20005 |
|
20006 |
|
20007 |
|
20008 |
|
20009 |
|
20010 |
|
20011 |
|
20012 | Graph3d.prototype._redrawDotColorGraphPoint = function (ctx, point) {
|
20013 | var colors = this._getColorsColor(point);
|
20014 |
|
20015 | this._drawCircle(ctx, point, colors.fill, colors.border);
|
20016 | };
|
20017 |
|
20018 |
|
20019 |
|
20020 |
|
20021 |
|
20022 |
|
20023 |
|
20024 |
|
20025 |
|
20026 | Graph3d.prototype._redrawDotSizeGraphPoint = function (ctx, point) {
|
20027 | var dotSize = this._dotSize();
|
20028 |
|
20029 | var fraction = (point.point.value - this.valueRange.min) / this.valueRange.range();
|
20030 | var sizeMin = dotSize * this.dotSizeMinFraction;
|
20031 | var sizeRange = dotSize * this.dotSizeMaxFraction - sizeMin;
|
20032 | var size = sizeMin + sizeRange * fraction;
|
20033 |
|
20034 | var colors = this._getColorsSize();
|
20035 |
|
20036 | this._drawCircle(ctx, point, colors.fill, colors.border, size);
|
20037 | };
|
20038 |
|
20039 |
|
20040 |
|
20041 |
|
20042 |
|
20043 |
|
20044 |
|
20045 |
|
20046 |
|
20047 | Graph3d.prototype._redrawSurfaceGraphPoint = function (ctx, point) {
|
20048 | var right = point.pointRight;
|
20049 | var top = point.pointTop;
|
20050 | var cross = point.pointCross;
|
20051 |
|
20052 | if (point === undefined || right === undefined || top === undefined || cross === undefined) {
|
20053 | return;
|
20054 | }
|
20055 |
|
20056 | var topSideVisible = true;
|
20057 | var fillStyle;
|
20058 | var strokeStyle;
|
20059 |
|
20060 | if (this.showGrayBottom || this.showShadow) {
|
20061 |
|
20062 |
|
20063 |
|
20064 |
|
20065 | var aDiff = Point3d_1.subtract(cross.trans, point.trans);
|
20066 | var bDiff = Point3d_1.subtract(top.trans, right.trans);
|
20067 | var crossproduct = Point3d_1.crossProduct(aDiff, bDiff);
|
20068 | var len = crossproduct.length();
|
20069 |
|
20070 | topSideVisible = crossproduct.z > 0;
|
20071 | }
|
20072 |
|
20073 | if (topSideVisible) {
|
20074 |
|
20075 | var zAvg = (point.point.z + right.point.z + top.point.z + cross.point.z) / 4;
|
20076 | var h = (1 - (zAvg - this.zRange.min) * this.scale.z / this.verticalRatio) * 240;
|
20077 | var s = 1;
|
20078 |
|
20079 | var v;
|
20080 |
|
20081 | if (this.showShadow) {
|
20082 | v = Math.min(1 + crossproduct.x / len / 2, 1);
|
20083 |
|
20084 | fillStyle = this._hsv2rgb(h, s, v);
|
20085 | strokeStyle = fillStyle;
|
20086 | } else {
|
20087 | v = 1;
|
20088 | fillStyle = this._hsv2rgb(h, s, v);
|
20089 | strokeStyle = this.axisColor;
|
20090 | }
|
20091 | } else {
|
20092 | fillStyle = 'gray';
|
20093 | strokeStyle = this.axisColor;
|
20094 | }
|
20095 |
|
20096 | ctx.lineWidth = this._getStrokeWidth(point);
|
20097 |
|
20098 | var points = [point, right, cross, top];
|
20099 |
|
20100 | this._polygon(ctx, points, fillStyle, strokeStyle);
|
20101 | };
|
20102 |
|
20103 |
|
20104 |
|
20105 |
|
20106 |
|
20107 |
|
20108 |
|
20109 |
|
20110 |
|
20111 |
|
20112 | Graph3d.prototype._drawGridLine = function (ctx, from, to) {
|
20113 | if (from === undefined || to === undefined) {
|
20114 | return;
|
20115 | }
|
20116 |
|
20117 |
|
20118 | var zAvg = (from.point.z + to.point.z) / 2;
|
20119 | var h = (1 - (zAvg - this.zRange.min) * this.scale.z / this.verticalRatio) * 240;
|
20120 | ctx.lineWidth = this._getStrokeWidth(from) * 2;
|
20121 | ctx.strokeStyle = this._hsv2rgb(h, 1, 1);
|
20122 |
|
20123 | this._line(ctx, from.screen, to.screen);
|
20124 | };
|
20125 |
|
20126 |
|
20127 |
|
20128 |
|
20129 |
|
20130 |
|
20131 |
|
20132 |
|
20133 |
|
20134 | Graph3d.prototype._redrawGridGraphPoint = function (ctx, point) {
|
20135 | this._drawGridLine(ctx, point, point.pointRight);
|
20136 |
|
20137 | this._drawGridLine(ctx, point, point.pointTop);
|
20138 | };
|
20139 |
|
20140 |
|
20141 |
|
20142 |
|
20143 |
|
20144 |
|
20145 |
|
20146 |
|
20147 |
|
20148 | Graph3d.prototype._redrawLineGraphPoint = function (ctx, point) {
|
20149 | if (point.pointNext === undefined) {
|
20150 | return;
|
20151 | }
|
20152 |
|
20153 | ctx.lineWidth = this._getStrokeWidth(point);
|
20154 | ctx.strokeStyle = this.dataColor.stroke;
|
20155 |
|
20156 | this._line(ctx, point.screen, point.pointNext.screen);
|
20157 | };
|
20158 |
|
20159 |
|
20160 |
|
20161 |
|
20162 |
|
20163 |
|
20164 | Graph3d.prototype._redrawDataGraph = function () {
|
20165 | var ctx = this._getContext();
|
20166 |
|
20167 | var i;
|
20168 | if (this.dataPoints === undefined || this.dataPoints.length <= 0) return;
|
20169 |
|
20170 | this._calcTranslations(this.dataPoints);
|
20171 |
|
20172 | for (i = 0; i < this.dataPoints.length; i++) {
|
20173 | var point = this.dataPoints[i];
|
20174 |
|
20175 | this._pointDrawingMethod.call(this, ctx, point);
|
20176 | }
|
20177 | };
|
20178 |
|
20179 |
|
20180 |
|
20181 |
|
20182 |
|
20183 |
|
20184 |
|
20185 |
|
20186 |
|
20187 |
|
20188 | Graph3d.prototype._storeMousePosition = function (event) {
|
20189 |
|
20190 | this.startMouseX = getMouseX(event);
|
20191 | this.startMouseY = getMouseY(event);
|
20192 | this._startCameraOffset = this.camera.getOffset();
|
20193 | };
|
20194 |
|
20195 |
|
20196 |
|
20197 |
|
20198 |
|
20199 |
|
20200 |
|
20201 | Graph3d.prototype._onMouseDown = function (event) {
|
20202 | event = event || window.event;
|
20203 |
|
20204 |
|
20205 | if (this.leftButtonDown) {
|
20206 | this._onMouseUp(event);
|
20207 | }
|
20208 |
|
20209 |
|
20210 | this.leftButtonDown = event.which ? event.which === 1 : event.button === 1;
|
20211 | if (!this.leftButtonDown && !this.touchDown) return;
|
20212 |
|
20213 | this._storeMousePosition(event);
|
20214 |
|
20215 | this.startStart = new Date(this.start);
|
20216 | this.startEnd = new Date(this.end);
|
20217 | this.startArmRotation = this.camera.getArmRotation();
|
20218 | this.frame.style.cursor = 'move';
|
20219 |
|
20220 |
|
20221 |
|
20222 | var me = this;
|
20223 |
|
20224 | this.onmousemove = function (event) {
|
20225 | me._onMouseMove(event);
|
20226 | };
|
20227 |
|
20228 | this.onmouseup = function (event) {
|
20229 | me._onMouseUp(event);
|
20230 | };
|
20231 |
|
20232 | util.addEventListener(document, 'mousemove', me.onmousemove);
|
20233 | util.addEventListener(document, 'mouseup', me.onmouseup);
|
20234 | util.preventDefault(event);
|
20235 | };
|
20236 |
|
20237 |
|
20238 |
|
20239 |
|
20240 |
|
20241 |
|
20242 |
|
20243 | Graph3d.prototype._onMouseMove = function (event) {
|
20244 | this.moving = true;
|
20245 | event = event || window.event;
|
20246 |
|
20247 | var diffX = parseFloat(getMouseX(event)) - this.startMouseX;
|
20248 | var diffY = parseFloat(getMouseY(event)) - this.startMouseY;
|
20249 |
|
20250 | if (event && event.ctrlKey === true) {
|
20251 |
|
20252 | var scaleX = this.frame.clientWidth * 0.5;
|
20253 | var scaleY = this.frame.clientHeight * 0.5;
|
20254 | var offXNew = (this._startCameraOffset.x || 0) - diffX / scaleX * this.camera.armLength * 0.8;
|
20255 | var offYNew = (this._startCameraOffset.y || 0) + diffY / scaleY * this.camera.armLength * 0.8;
|
20256 | this.camera.setOffset(offXNew, offYNew);
|
20257 |
|
20258 | this._storeMousePosition(event);
|
20259 | } else {
|
20260 | var horizontalNew = this.startArmRotation.horizontal + diffX / 200;
|
20261 | var verticalNew = this.startArmRotation.vertical + diffY / 200;
|
20262 | var snapAngle = 4;
|
20263 |
|
20264 | var snapValue = Math.sin(snapAngle / 360 * 2 * Math.PI);
|
20265 |
|
20266 |
|
20267 | if (Math.abs(Math.sin(horizontalNew)) < snapValue) {
|
20268 | horizontalNew = Math.round(horizontalNew / Math.PI) * Math.PI - 0.001;
|
20269 | }
|
20270 |
|
20271 | if (Math.abs(Math.cos(horizontalNew)) < snapValue) {
|
20272 | horizontalNew = (Math.round(horizontalNew / Math.PI - 0.5) + 0.5) * Math.PI - 0.001;
|
20273 | }
|
20274 |
|
20275 |
|
20276 | if (Math.abs(Math.sin(verticalNew)) < snapValue) {
|
20277 | verticalNew = Math.round(verticalNew / Math.PI) * Math.PI;
|
20278 | }
|
20279 |
|
20280 | if (Math.abs(Math.cos(verticalNew)) < snapValue) {
|
20281 | verticalNew = (Math.round(verticalNew / Math.PI - 0.5) + 0.5) * Math.PI;
|
20282 | }
|
20283 |
|
20284 | this.camera.setArmRotation(horizontalNew, verticalNew);
|
20285 | }
|
20286 |
|
20287 | this.redraw();
|
20288 |
|
20289 | var parameters = this.getCameraPosition();
|
20290 | this.emit('cameraPositionChange', parameters);
|
20291 | util.preventDefault(event);
|
20292 | };
|
20293 |
|
20294 |
|
20295 |
|
20296 |
|
20297 |
|
20298 |
|
20299 |
|
20300 | Graph3d.prototype._onMouseUp = function (event) {
|
20301 | this.frame.style.cursor = 'auto';
|
20302 | this.leftButtonDown = false;
|
20303 |
|
20304 | util.removeEventListener(document, 'mousemove', this.onmousemove);
|
20305 | util.removeEventListener(document, 'mouseup', this.onmouseup);
|
20306 | util.preventDefault(event);
|
20307 | };
|
20308 |
|
20309 |
|
20310 |
|
20311 |
|
20312 |
|
20313 | Graph3d.prototype._onClick = function (event) {
|
20314 | if (!this.onclick_callback) return;
|
20315 |
|
20316 | if (!this.moving) {
|
20317 | var boundingRect = this.frame.getBoundingClientRect();
|
20318 | var mouseX = getMouseX(event) - boundingRect.left;
|
20319 | var mouseY = getMouseY(event) - boundingRect.top;
|
20320 |
|
20321 | var dataPoint = this._dataPointFromXY(mouseX, mouseY);
|
20322 |
|
20323 | if (dataPoint) this.onclick_callback(dataPoint.point.data);
|
20324 | } else {
|
20325 |
|
20326 | this.moving = false;
|
20327 | }
|
20328 |
|
20329 | util.preventDefault(event);
|
20330 | };
|
20331 |
|
20332 |
|
20333 |
|
20334 |
|
20335 |
|
20336 |
|
20337 | Graph3d.prototype._onTooltip = function (event) {
|
20338 | var delay = 300;
|
20339 |
|
20340 | var boundingRect = this.frame.getBoundingClientRect();
|
20341 | var mouseX = getMouseX(event) - boundingRect.left;
|
20342 | var mouseY = getMouseY(event) - boundingRect.top;
|
20343 |
|
20344 | if (!this.showTooltip) {
|
20345 | return;
|
20346 | }
|
20347 |
|
20348 | if (this.tooltipTimeout) {
|
20349 | clearTimeout(this.tooltipTimeout);
|
20350 | }
|
20351 |
|
20352 |
|
20353 | if (this.leftButtonDown) {
|
20354 | this._hideTooltip();
|
20355 |
|
20356 | return;
|
20357 | }
|
20358 |
|
20359 | if (this.tooltip && this.tooltip.dataPoint) {
|
20360 |
|
20361 | var dataPoint = this._dataPointFromXY(mouseX, mouseY);
|
20362 |
|
20363 | if (dataPoint !== this.tooltip.dataPoint) {
|
20364 |
|
20365 | if (dataPoint) {
|
20366 | this._showTooltip(dataPoint);
|
20367 | } else {
|
20368 | this._hideTooltip();
|
20369 | }
|
20370 | }
|
20371 | } else {
|
20372 |
|
20373 | var me = this;
|
20374 | this.tooltipTimeout = setTimeout(function () {
|
20375 | me.tooltipTimeout = null;
|
20376 |
|
20377 | var dataPoint = me._dataPointFromXY(mouseX, mouseY);
|
20378 |
|
20379 | if (dataPoint) {
|
20380 | me._showTooltip(dataPoint);
|
20381 | }
|
20382 | }, delay);
|
20383 | }
|
20384 | };
|
20385 |
|
20386 |
|
20387 |
|
20388 |
|
20389 |
|
20390 |
|
20391 | Graph3d.prototype._onTouchStart = function (event) {
|
20392 | this.touchDown = true;
|
20393 | var me = this;
|
20394 |
|
20395 | this.ontouchmove = function (event) {
|
20396 | me._onTouchMove(event);
|
20397 | };
|
20398 |
|
20399 | this.ontouchend = function (event) {
|
20400 | me._onTouchEnd(event);
|
20401 | };
|
20402 |
|
20403 | util.addEventListener(document, 'touchmove', me.ontouchmove);
|
20404 | util.addEventListener(document, 'touchend', me.ontouchend);
|
20405 |
|
20406 | this._onMouseDown(event);
|
20407 | };
|
20408 |
|
20409 |
|
20410 |
|
20411 |
|
20412 |
|
20413 |
|
20414 | Graph3d.prototype._onTouchMove = function (event) {
|
20415 | this._onMouseMove(event);
|
20416 | };
|
20417 |
|
20418 |
|
20419 |
|
20420 |
|
20421 |
|
20422 |
|
20423 | Graph3d.prototype._onTouchEnd = function (event) {
|
20424 | this.touchDown = false;
|
20425 | util.removeEventListener(document, 'touchmove', this.ontouchmove);
|
20426 | util.removeEventListener(document, 'touchend', this.ontouchend);
|
20427 |
|
20428 | this._onMouseUp(event);
|
20429 | };
|
20430 |
|
20431 |
|
20432 |
|
20433 |
|
20434 |
|
20435 |
|
20436 |
|
20437 | Graph3d.prototype._onWheel = function (event) {
|
20438 | if (!event)
|
20439 |
|
20440 | event = window.event;
|
20441 |
|
20442 | if (this.zoomable && (!this.ctrlToZoom || event.ctrlKey)) {
|
20443 |
|
20444 | var delta = 0;
|
20445 |
|
20446 | if (event.wheelDelta) {
|
20447 |
|
20448 | delta = event.wheelDelta / 120;
|
20449 | } else if (event.detail) {
|
20450 |
|
20451 |
|
20452 |
|
20453 | delta = -event.detail / 3;
|
20454 | }
|
20455 |
|
20456 |
|
20457 |
|
20458 |
|
20459 | if (delta) {
|
20460 | var oldLength = this.camera.getArmLength();
|
20461 | var newLength = oldLength * (1 - delta / 10);
|
20462 | this.camera.setArmLength(newLength);
|
20463 | this.redraw();
|
20464 |
|
20465 | this._hideTooltip();
|
20466 | }
|
20467 |
|
20468 |
|
20469 | var parameters = this.getCameraPosition();
|
20470 | this.emit('cameraPositionChange', parameters);
|
20471 |
|
20472 |
|
20473 |
|
20474 | util.preventDefault(event);
|
20475 | }
|
20476 | };
|
20477 |
|
20478 |
|
20479 |
|
20480 |
|
20481 |
|
20482 |
|
20483 |
|
20484 |
|
20485 |
|
20486 |
|
20487 |
|
20488 | Graph3d.prototype._insideTriangle = function (point, triangle) {
|
20489 | var a = triangle[0],
|
20490 | b = triangle[1],
|
20491 | c = triangle[2];
|
20492 | |
20493 |
|
20494 |
|
20495 |
|
20496 |
|
20497 |
|
20498 | function sign(x) {
|
20499 | return x > 0 ? 1 : x < 0 ? -1 : 0;
|
20500 | }
|
20501 |
|
20502 | var as = sign((b.x - a.x) * (point.y - a.y) - (b.y - a.y) * (point.x - a.x));
|
20503 | var bs = sign((c.x - b.x) * (point.y - b.y) - (c.y - b.y) * (point.x - b.x));
|
20504 | var cs = sign((a.x - c.x) * (point.y - c.y) - (a.y - c.y) * (point.x - c.x));
|
20505 |
|
20506 | return (as == 0 || bs == 0 || as == bs) && (bs == 0 || cs == 0 || bs == cs) && (as == 0 || cs == 0 || as == cs);
|
20507 | };
|
20508 |
|
20509 |
|
20510 |
|
20511 |
|
20512 |
|
20513 |
|
20514 |
|
20515 |
|
20516 |
|
20517 |
|
20518 |
|
20519 | Graph3d.prototype._dataPointFromXY = function (x, y) {
|
20520 | var i,
|
20521 | distMax = 100,
|
20522 |
|
20523 | dataPoint = null,
|
20524 | closestDataPoint = null,
|
20525 | closestDist = null,
|
20526 | center = new Point2d_1(x, y);
|
20527 |
|
20528 | if (this.style === Graph3d.STYLE.BAR || this.style === Graph3d.STYLE.BARCOLOR || this.style === Graph3d.STYLE.BARSIZE) {
|
20529 |
|
20530 | for (i = this.dataPoints.length - 1; i >= 0; i--) {
|
20531 | dataPoint = this.dataPoints[i];
|
20532 | var surfaces = dataPoint.surfaces;
|
20533 |
|
20534 | if (surfaces) {
|
20535 | for (var s = surfaces.length - 1; s >= 0; s--) {
|
20536 |
|
20537 | var surface = surfaces[s];
|
20538 | var corners = surface.corners;
|
20539 | var triangle1 = [corners[0].screen, corners[1].screen, corners[2].screen];
|
20540 | var triangle2 = [corners[2].screen, corners[3].screen, corners[0].screen];
|
20541 |
|
20542 | if (this._insideTriangle(center, triangle1) || this._insideTriangle(center, triangle2)) {
|
20543 |
|
20544 | return dataPoint;
|
20545 | }
|
20546 | }
|
20547 | }
|
20548 | }
|
20549 | } else {
|
20550 |
|
20551 | for (i = 0; i < this.dataPoints.length; i++) {
|
20552 | dataPoint = this.dataPoints[i];
|
20553 | var point = dataPoint.screen;
|
20554 |
|
20555 | if (point) {
|
20556 | var distX = Math.abs(x - point.x);
|
20557 | var distY = Math.abs(y - point.y);
|
20558 | var dist = Math.sqrt(distX * distX + distY * distY);
|
20559 |
|
20560 | if ((closestDist === null || dist < closestDist) && dist < distMax) {
|
20561 | closestDist = dist;
|
20562 | closestDataPoint = dataPoint;
|
20563 | }
|
20564 | }
|
20565 | }
|
20566 | }
|
20567 |
|
20568 | return closestDataPoint;
|
20569 | };
|
20570 |
|
20571 |
|
20572 |
|
20573 |
|
20574 |
|
20575 |
|
20576 |
|
20577 |
|
20578 | Graph3d.prototype.hasBars = function (style) {
|
20579 | return style == Graph3d.STYLE.BAR || style == Graph3d.STYLE.BARCOLOR || style == Graph3d.STYLE.BARSIZE;
|
20580 | };
|
20581 |
|
20582 |
|
20583 |
|
20584 |
|
20585 |
|
20586 |
|
20587 |
|
20588 | Graph3d.prototype._showTooltip = function (dataPoint) {
|
20589 | var content, line, dot;
|
20590 |
|
20591 | if (!this.tooltip) {
|
20592 | content = document.createElement('div');
|
20593 | Object.assign(content.style, {}, this.tooltipStyle.content);
|
20594 | content.style.position = 'absolute';
|
20595 | line = document.createElement('div');
|
20596 | Object.assign(line.style, {}, this.tooltipStyle.line);
|
20597 | line.style.position = 'absolute';
|
20598 | dot = document.createElement('div');
|
20599 | Object.assign(dot.style, {}, this.tooltipStyle.dot);
|
20600 | dot.style.position = 'absolute';
|
20601 | this.tooltip = {
|
20602 | dataPoint: null,
|
20603 | dom: {
|
20604 | content: content,
|
20605 | line: line,
|
20606 | dot: dot
|
20607 | }
|
20608 | };
|
20609 | } else {
|
20610 | content = this.tooltip.dom.content;
|
20611 | line = this.tooltip.dom.line;
|
20612 | dot = this.tooltip.dom.dot;
|
20613 | }
|
20614 |
|
20615 | this._hideTooltip();
|
20616 |
|
20617 | this.tooltip.dataPoint = dataPoint;
|
20618 |
|
20619 | if (typeof this.showTooltip === 'function') {
|
20620 | content.innerHTML = this.showTooltip(dataPoint.point);
|
20621 | } else {
|
20622 | content.innerHTML = '<table>' + '<tr><td>' + this.xLabel + ':</td><td>' + dataPoint.point.x + '</td></tr>' + '<tr><td>' + this.yLabel + ':</td><td>' + dataPoint.point.y + '</td></tr>' + '<tr><td>' + this.zLabel + ':</td><td>' + dataPoint.point.z + '</td></tr>' + '</table>';
|
20623 | }
|
20624 |
|
20625 | content.style.left = '0';
|
20626 | content.style.top = '0';
|
20627 | this.frame.appendChild(content);
|
20628 | this.frame.appendChild(line);
|
20629 | this.frame.appendChild(dot);
|
20630 |
|
20631 | var contentWidth = content.offsetWidth;
|
20632 | var contentHeight = content.offsetHeight;
|
20633 | var lineHeight = line.offsetHeight;
|
20634 | var dotWidth = dot.offsetWidth;
|
20635 | var dotHeight = dot.offsetHeight;
|
20636 | var left = dataPoint.screen.x - contentWidth / 2;
|
20637 | left = Math.min(Math.max(left, 10), this.frame.clientWidth - 10 - contentWidth);
|
20638 | line.style.left = dataPoint.screen.x + 'px';
|
20639 | line.style.top = dataPoint.screen.y - lineHeight + 'px';
|
20640 | content.style.left = left + 'px';
|
20641 | content.style.top = dataPoint.screen.y - lineHeight - contentHeight + 'px';
|
20642 | dot.style.left = dataPoint.screen.x - dotWidth / 2 + 'px';
|
20643 | dot.style.top = dataPoint.screen.y - dotHeight / 2 + 'px';
|
20644 | };
|
20645 |
|
20646 |
|
20647 |
|
20648 |
|
20649 |
|
20650 |
|
20651 | Graph3d.prototype._hideTooltip = function () {
|
20652 | if (this.tooltip) {
|
20653 | this.tooltip.dataPoint = null;
|
20654 |
|
20655 | for (var prop in this.tooltip.dom) {
|
20656 | if (this.tooltip.dom.hasOwnProperty(prop)) {
|
20657 | var elem = this.tooltip.dom[prop];
|
20658 |
|
20659 | if (elem && elem.parentNode) {
|
20660 | elem.parentNode.removeChild(elem);
|
20661 | }
|
20662 | }
|
20663 | }
|
20664 | }
|
20665 | };
|
20666 |
|
20667 |
|
20668 |
|
20669 |
|
20670 |
|
20671 |
|
20672 |
|
20673 |
|
20674 |
|
20675 |
|
20676 | function getMouseX(event) {
|
20677 | if ('clientX' in event) return event.clientX;
|
20678 | return event.targetTouches[0] && event.targetTouches[0].clientX || 0;
|
20679 | }
|
20680 |
|
20681 |
|
20682 |
|
20683 |
|
20684 |
|
20685 |
|
20686 |
|
20687 |
|
20688 | function getMouseY(event) {
|
20689 | if ('clientY' in event) return event.clientY;
|
20690 | return event.targetTouches[0] && event.targetTouches[0].clientY || 0;
|
20691 | }
|
20692 |
|
20693 |
|
20694 |
|
20695 |
|
20696 |
|
20697 |
|
20698 |
|
20699 |
|
20700 |
|
20701 |
|
20702 |
|
20703 |
|
20704 |
|
20705 |
|
20706 |
|
20707 |
|
20708 |
|
20709 |
|
20710 | Graph3d.prototype.setCameraPosition = function (pos) {
|
20711 | Settings.setCameraPosition(pos, this);
|
20712 | this.redraw();
|
20713 | };
|
20714 |
|
20715 |
|
20716 |
|
20717 |
|
20718 |
|
20719 |
|
20720 |
|
20721 |
|
20722 |
|
20723 |
|
20724 | Graph3d.prototype.setSize = function (width, height) {
|
20725 | this._setSize(width, height);
|
20726 |
|
20727 | this.redraw();
|
20728 | };
|
20729 |
|
20730 |
|
20731 |
|
20732 |
|
20733 | var Graph3d_1 = Graph3d;
|
20734 |
|
20735 | var moment$2 = createCommonjsModule$1(function (module, exports) {
|
20736 |
|
20737 | (function (global, factory) {
|
20738 | module.exports = factory() ;
|
20739 | })(commonjsGlobal$1, function () {
|
20740 |
|
20741 | var hookCallback;
|
20742 |
|
20743 | function hooks() {
|
20744 | return hookCallback.apply(null, arguments);
|
20745 | }
|
20746 |
|
20747 |
|
20748 |
|
20749 | function setHookCallback(callback) {
|
20750 | hookCallback = callback;
|
20751 | }
|
20752 |
|
20753 | function isArray(input) {
|
20754 | return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
|
20755 | }
|
20756 |
|
20757 | function isObject(input) {
|
20758 |
|
20759 |
|
20760 | return input != null && Object.prototype.toString.call(input) === '[object Object]';
|
20761 | }
|
20762 |
|
20763 | function isObjectEmpty(obj) {
|
20764 | if (Object.getOwnPropertyNames) {
|
20765 | return Object.getOwnPropertyNames(obj).length === 0;
|
20766 | } else {
|
20767 | var k;
|
20768 |
|
20769 | for (k in obj) {
|
20770 | if (obj.hasOwnProperty(k)) {
|
20771 | return false;
|
20772 | }
|
20773 | }
|
20774 |
|
20775 | return true;
|
20776 | }
|
20777 | }
|
20778 |
|
20779 | function isUndefined(input) {
|
20780 | return input === void 0;
|
20781 | }
|
20782 |
|
20783 | function isNumber(input) {
|
20784 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
|
20785 | }
|
20786 |
|
20787 | function isDate(input) {
|
20788 | return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
20789 | }
|
20790 |
|
20791 | function map(arr, fn) {
|
20792 | var res = [],
|
20793 | i;
|
20794 |
|
20795 | for (i = 0; i < arr.length; ++i) {
|
20796 | res.push(fn(arr[i], i));
|
20797 | }
|
20798 |
|
20799 | return res;
|
20800 | }
|
20801 |
|
20802 | function hasOwnProp(a, b) {
|
20803 | return Object.prototype.hasOwnProperty.call(a, b);
|
20804 | }
|
20805 |
|
20806 | function extend(a, b) {
|
20807 | for (var i in b) {
|
20808 | if (hasOwnProp(b, i)) {
|
20809 | a[i] = b[i];
|
20810 | }
|
20811 | }
|
20812 |
|
20813 | if (hasOwnProp(b, 'toString')) {
|
20814 | a.toString = b.toString;
|
20815 | }
|
20816 |
|
20817 | if (hasOwnProp(b, 'valueOf')) {
|
20818 | a.valueOf = b.valueOf;
|
20819 | }
|
20820 |
|
20821 | return a;
|
20822 | }
|
20823 |
|
20824 | function createUTC(input, format, locale, strict) {
|
20825 | return createLocalOrUTC(input, format, locale, strict, true).utc();
|
20826 | }
|
20827 |
|
20828 | function defaultParsingFlags() {
|
20829 |
|
20830 | return {
|
20831 | empty: false,
|
20832 | unusedTokens: [],
|
20833 | unusedInput: [],
|
20834 | overflow: -2,
|
20835 | charsLeftOver: 0,
|
20836 | nullInput: false,
|
20837 | invalidMonth: null,
|
20838 | invalidFormat: false,
|
20839 | userInvalidated: false,
|
20840 | iso: false,
|
20841 | parsedDateParts: [],
|
20842 | meridiem: null,
|
20843 | rfc2822: false,
|
20844 | weekdayMismatch: false
|
20845 | };
|
20846 | }
|
20847 |
|
20848 | function getParsingFlags(m) {
|
20849 | if (m._pf == null) {
|
20850 | m._pf = defaultParsingFlags();
|
20851 | }
|
20852 |
|
20853 | return m._pf;
|
20854 | }
|
20855 |
|
20856 | var some;
|
20857 |
|
20858 | if (Array.prototype.some) {
|
20859 | some = Array.prototype.some;
|
20860 | } else {
|
20861 | some = function (fun) {
|
20862 | var t = Object(this);
|
20863 | var len = t.length >>> 0;
|
20864 |
|
20865 | for (var i = 0; i < len; i++) {
|
20866 | if (i in t && fun.call(this, t[i], i, t)) {
|
20867 | return true;
|
20868 | }
|
20869 | }
|
20870 |
|
20871 | return false;
|
20872 | };
|
20873 | }
|
20874 |
|
20875 | function isValid(m) {
|
20876 | if (m._isValid == null) {
|
20877 | var flags = getParsingFlags(m);
|
20878 | var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
20879 | return i != null;
|
20880 | });
|
20881 | var isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || flags.meridiem && parsedParts);
|
20882 |
|
20883 | if (m._strict) {
|
20884 | isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === undefined;
|
20885 | }
|
20886 |
|
20887 | if (Object.isFrozen == null || !Object.isFrozen(m)) {
|
20888 | m._isValid = isNowValid;
|
20889 | } else {
|
20890 | return isNowValid;
|
20891 | }
|
20892 | }
|
20893 |
|
20894 | return m._isValid;
|
20895 | }
|
20896 |
|
20897 | function createInvalid(flags) {
|
20898 | var m = createUTC(NaN);
|
20899 |
|
20900 | if (flags != null) {
|
20901 | extend(getParsingFlags(m), flags);
|
20902 | } else {
|
20903 | getParsingFlags(m).userInvalidated = true;
|
20904 | }
|
20905 |
|
20906 | return m;
|
20907 | }
|
20908 |
|
20909 |
|
20910 |
|
20911 | var momentProperties = hooks.momentProperties = [];
|
20912 |
|
20913 | function copyConfig(to, from) {
|
20914 | var i, prop, val;
|
20915 |
|
20916 | if (!isUndefined(from._isAMomentObject)) {
|
20917 | to._isAMomentObject = from._isAMomentObject;
|
20918 | }
|
20919 |
|
20920 | if (!isUndefined(from._i)) {
|
20921 | to._i = from._i;
|
20922 | }
|
20923 |
|
20924 | if (!isUndefined(from._f)) {
|
20925 | to._f = from._f;
|
20926 | }
|
20927 |
|
20928 | if (!isUndefined(from._l)) {
|
20929 | to._l = from._l;
|
20930 | }
|
20931 |
|
20932 | if (!isUndefined(from._strict)) {
|
20933 | to._strict = from._strict;
|
20934 | }
|
20935 |
|
20936 | if (!isUndefined(from._tzm)) {
|
20937 | to._tzm = from._tzm;
|
20938 | }
|
20939 |
|
20940 | if (!isUndefined(from._isUTC)) {
|
20941 | to._isUTC = from._isUTC;
|
20942 | }
|
20943 |
|
20944 | if (!isUndefined(from._offset)) {
|
20945 | to._offset = from._offset;
|
20946 | }
|
20947 |
|
20948 | if (!isUndefined(from._pf)) {
|
20949 | to._pf = getParsingFlags(from);
|
20950 | }
|
20951 |
|
20952 | if (!isUndefined(from._locale)) {
|
20953 | to._locale = from._locale;
|
20954 | }
|
20955 |
|
20956 | if (momentProperties.length > 0) {
|
20957 | for (i = 0; i < momentProperties.length; i++) {
|
20958 | prop = momentProperties[i];
|
20959 | val = from[prop];
|
20960 |
|
20961 | if (!isUndefined(val)) {
|
20962 | to[prop] = val;
|
20963 | }
|
20964 | }
|
20965 | }
|
20966 |
|
20967 | return to;
|
20968 | }
|
20969 |
|
20970 | var updateInProgress = false;
|
20971 |
|
20972 | function Moment(config) {
|
20973 | copyConfig(this, config);
|
20974 | this._d = new Date(config._d != null ? config._d.getTime() : NaN);
|
20975 |
|
20976 | if (!this.isValid()) {
|
20977 | this._d = new Date(NaN);
|
20978 | }
|
20979 |
|
20980 |
|
20981 |
|
20982 | if (updateInProgress === false) {
|
20983 | updateInProgress = true;
|
20984 | hooks.updateOffset(this);
|
20985 | updateInProgress = false;
|
20986 | }
|
20987 | }
|
20988 |
|
20989 | function isMoment(obj) {
|
20990 | return obj instanceof Moment || obj != null && obj._isAMomentObject != null;
|
20991 | }
|
20992 |
|
20993 | function absFloor(number) {
|
20994 | if (number < 0) {
|
20995 |
|
20996 | return Math.ceil(number) || 0;
|
20997 | } else {
|
20998 | return Math.floor(number);
|
20999 | }
|
21000 | }
|
21001 |
|
21002 | function toInt(argumentForCoercion) {
|
21003 | var coercedNumber = +argumentForCoercion,
|
21004 | value = 0;
|
21005 |
|
21006 | if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
21007 | value = absFloor(coercedNumber);
|
21008 | }
|
21009 |
|
21010 | return value;
|
21011 | }
|
21012 |
|
21013 |
|
21014 | function compareArrays(array1, array2, dontConvert) {
|
21015 | var len = Math.min(array1.length, array2.length),
|
21016 | lengthDiff = Math.abs(array1.length - array2.length),
|
21017 | diffs = 0,
|
21018 | i;
|
21019 |
|
21020 | for (i = 0; i < len; i++) {
|
21021 | if (dontConvert && array1[i] !== array2[i] || !dontConvert && toInt(array1[i]) !== toInt(array2[i])) {
|
21022 | diffs++;
|
21023 | }
|
21024 | }
|
21025 |
|
21026 | return diffs + lengthDiff;
|
21027 | }
|
21028 |
|
21029 | function warn(msg) {
|
21030 | if (hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
|
21031 | console.warn('Deprecation warning: ' + msg);
|
21032 | }
|
21033 | }
|
21034 |
|
21035 | function deprecate(msg, fn) {
|
21036 | var firstTime = true;
|
21037 | return extend(function () {
|
21038 | if (hooks.deprecationHandler != null) {
|
21039 | hooks.deprecationHandler(null, msg);
|
21040 | }
|
21041 |
|
21042 | if (firstTime) {
|
21043 | var args = [];
|
21044 | var arg;
|
21045 |
|
21046 | for (var i = 0; i < arguments.length; i++) {
|
21047 | arg = '';
|
21048 |
|
21049 | if (typeof arguments[i] === 'object') {
|
21050 | arg += '\n[' + i + '] ';
|
21051 |
|
21052 | for (var key in arguments[0]) {
|
21053 | arg += key + ': ' + arguments[0][key] + ', ';
|
21054 | }
|
21055 |
|
21056 | arg = arg.slice(0, -2);
|
21057 | } else {
|
21058 | arg = arguments[i];
|
21059 | }
|
21060 |
|
21061 | args.push(arg);
|
21062 | }
|
21063 |
|
21064 | warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + new Error().stack);
|
21065 | firstTime = false;
|
21066 | }
|
21067 |
|
21068 | return fn.apply(this, arguments);
|
21069 | }, fn);
|
21070 | }
|
21071 |
|
21072 | var deprecations = {};
|
21073 |
|
21074 | function deprecateSimple(name, msg) {
|
21075 | if (hooks.deprecationHandler != null) {
|
21076 | hooks.deprecationHandler(name, msg);
|
21077 | }
|
21078 |
|
21079 | if (!deprecations[name]) {
|
21080 | warn(msg);
|
21081 | deprecations[name] = true;
|
21082 | }
|
21083 | }
|
21084 |
|
21085 | hooks.suppressDeprecationWarnings = false;
|
21086 | hooks.deprecationHandler = null;
|
21087 |
|
21088 | function isFunction(input) {
|
21089 | return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
21090 | }
|
21091 |
|
21092 | function set(config) {
|
21093 | var prop, i;
|
21094 |
|
21095 | for (i in config) {
|
21096 | prop = config[i];
|
21097 |
|
21098 | if (isFunction(prop)) {
|
21099 | this[i] = prop;
|
21100 | } else {
|
21101 | this['_' + i] = prop;
|
21102 | }
|
21103 | }
|
21104 |
|
21105 | this._config = config;
|
21106 |
|
21107 |
|
21108 |
|
21109 | this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source);
|
21110 | }
|
21111 |
|
21112 | function mergeConfigs(parentConfig, childConfig) {
|
21113 | var res = extend({}, parentConfig),
|
21114 | prop;
|
21115 |
|
21116 | for (prop in childConfig) {
|
21117 | if (hasOwnProp(childConfig, prop)) {
|
21118 | if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
|
21119 | res[prop] = {};
|
21120 | extend(res[prop], parentConfig[prop]);
|
21121 | extend(res[prop], childConfig[prop]);
|
21122 | } else if (childConfig[prop] != null) {
|
21123 | res[prop] = childConfig[prop];
|
21124 | } else {
|
21125 | delete res[prop];
|
21126 | }
|
21127 | }
|
21128 | }
|
21129 |
|
21130 | for (prop in parentConfig) {
|
21131 | if (hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop])) {
|
21132 |
|
21133 | res[prop] = extend({}, res[prop]);
|
21134 | }
|
21135 | }
|
21136 |
|
21137 | return res;
|
21138 | }
|
21139 |
|
21140 | function Locale(config) {
|
21141 | if (config != null) {
|
21142 | this.set(config);
|
21143 | }
|
21144 | }
|
21145 |
|
21146 | var keys;
|
21147 |
|
21148 | if (Object.keys) {
|
21149 | keys = Object.keys;
|
21150 | } else {
|
21151 | keys = function (obj) {
|
21152 | var i,
|
21153 | res = [];
|
21154 |
|
21155 | for (i in obj) {
|
21156 | if (hasOwnProp(obj, i)) {
|
21157 | res.push(i);
|
21158 | }
|
21159 | }
|
21160 |
|
21161 | return res;
|
21162 | };
|
21163 | }
|
21164 |
|
21165 | var defaultCalendar = {
|
21166 | sameDay: '[Today at] LT',
|
21167 | nextDay: '[Tomorrow at] LT',
|
21168 | nextWeek: 'dddd [at] LT',
|
21169 | lastDay: '[Yesterday at] LT',
|
21170 | lastWeek: '[Last] dddd [at] LT',
|
21171 | sameElse: 'L'
|
21172 | };
|
21173 |
|
21174 | function calendar(key, mom, now) {
|
21175 | var output = this._calendar[key] || this._calendar['sameElse'];
|
21176 | return isFunction(output) ? output.call(mom, now) : output;
|
21177 | }
|
21178 |
|
21179 | var defaultLongDateFormat = {
|
21180 | LTS: 'h:mm:ss A',
|
21181 | LT: 'h:mm A',
|
21182 | L: 'MM/DD/YYYY',
|
21183 | LL: 'MMMM D, YYYY',
|
21184 | LLL: 'MMMM D, YYYY h:mm A',
|
21185 | LLLL: 'dddd, MMMM D, YYYY h:mm A'
|
21186 | };
|
21187 |
|
21188 | function longDateFormat(key) {
|
21189 | var format = this._longDateFormat[key],
|
21190 | formatUpper = this._longDateFormat[key.toUpperCase()];
|
21191 |
|
21192 | if (format || !formatUpper) {
|
21193 | return format;
|
21194 | }
|
21195 |
|
21196 | this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
|
21197 | return val.slice(1);
|
21198 | });
|
21199 | return this._longDateFormat[key];
|
21200 | }
|
21201 |
|
21202 | var defaultInvalidDate = 'Invalid date';
|
21203 |
|
21204 | function invalidDate() {
|
21205 | return this._invalidDate;
|
21206 | }
|
21207 |
|
21208 | var defaultOrdinal = '%d';
|
21209 | var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
|
21210 |
|
21211 | function ordinal(number) {
|
21212 | return this._ordinal.replace('%d', number);
|
21213 | }
|
21214 |
|
21215 | var defaultRelativeTime = {
|
21216 | future: 'in %s',
|
21217 | past: '%s ago',
|
21218 | s: 'a few seconds',
|
21219 | ss: '%d seconds',
|
21220 | m: 'a minute',
|
21221 | mm: '%d minutes',
|
21222 | h: 'an hour',
|
21223 | hh: '%d hours',
|
21224 | d: 'a day',
|
21225 | dd: '%d days',
|
21226 | M: 'a month',
|
21227 | MM: '%d months',
|
21228 | y: 'a year',
|
21229 | yy: '%d years'
|
21230 | };
|
21231 |
|
21232 | function relativeTime(number, withoutSuffix, string, isFuture) {
|
21233 | var output = this._relativeTime[string];
|
21234 | return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number);
|
21235 | }
|
21236 |
|
21237 | function pastFuture(diff, output) {
|
21238 | var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
21239 | return isFunction(format) ? format(output) : format.replace(/%s/i, output);
|
21240 | }
|
21241 |
|
21242 | var aliases = {};
|
21243 |
|
21244 | function addUnitAlias(unit, shorthand) {
|
21245 | var lowerCase = unit.toLowerCase();
|
21246 | aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
|
21247 | }
|
21248 |
|
21249 | function normalizeUnits(units) {
|
21250 | return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
|
21251 | }
|
21252 |
|
21253 | function normalizeObjectUnits(inputObject) {
|
21254 | var normalizedInput = {},
|
21255 | normalizedProp,
|
21256 | prop;
|
21257 |
|
21258 | for (prop in inputObject) {
|
21259 | if (hasOwnProp(inputObject, prop)) {
|
21260 | normalizedProp = normalizeUnits(prop);
|
21261 |
|
21262 | if (normalizedProp) {
|
21263 | normalizedInput[normalizedProp] = inputObject[prop];
|
21264 | }
|
21265 | }
|
21266 | }
|
21267 |
|
21268 | return normalizedInput;
|
21269 | }
|
21270 |
|
21271 | var priorities = {};
|
21272 |
|
21273 | function addUnitPriority(unit, priority) {
|
21274 | priorities[unit] = priority;
|
21275 | }
|
21276 |
|
21277 | function getPrioritizedUnits(unitsObj) {
|
21278 | var units = [];
|
21279 |
|
21280 | for (var u in unitsObj) {
|
21281 | units.push({
|
21282 | unit: u,
|
21283 | priority: priorities[u]
|
21284 | });
|
21285 | }
|
21286 |
|
21287 | units.sort(function (a, b) {
|
21288 | return a.priority - b.priority;
|
21289 | });
|
21290 | return units;
|
21291 | }
|
21292 |
|
21293 | function zeroFill(number, targetLength, forceSign) {
|
21294 | var absNumber = '' + Math.abs(number),
|
21295 | zerosToFill = targetLength - absNumber.length,
|
21296 | sign = number >= 0;
|
21297 | return (sign ? forceSign ? '+' : '' : '-') + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
21298 | }
|
21299 |
|
21300 | var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
|
21301 | var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
21302 | var formatFunctions = {};
|
21303 | var formatTokenFunctions = {};
|
21304 |
|
21305 |
|
21306 |
|
21307 |
|
21308 | function addFormatToken(token, padded, ordinal, callback) {
|
21309 | var func = callback;
|
21310 |
|
21311 | if (typeof callback === 'string') {
|
21312 | func = function () {
|
21313 | return this[callback]();
|
21314 | };
|
21315 | }
|
21316 |
|
21317 | if (token) {
|
21318 | formatTokenFunctions[token] = func;
|
21319 | }
|
21320 |
|
21321 | if (padded) {
|
21322 | formatTokenFunctions[padded[0]] = function () {
|
21323 | return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
|
21324 | };
|
21325 | }
|
21326 |
|
21327 | if (ordinal) {
|
21328 | formatTokenFunctions[ordinal] = function () {
|
21329 | return this.localeData().ordinal(func.apply(this, arguments), token);
|
21330 | };
|
21331 | }
|
21332 | }
|
21333 |
|
21334 | function removeFormattingTokens(input) {
|
21335 | if (input.match(/\[[\s\S]/)) {
|
21336 | return input.replace(/^\[|\]$/g, '');
|
21337 | }
|
21338 |
|
21339 | return input.replace(/\\/g, '');
|
21340 | }
|
21341 |
|
21342 | function makeFormatFunction(format) {
|
21343 | var array = format.match(formattingTokens),
|
21344 | i,
|
21345 | length;
|
21346 |
|
21347 | for (i = 0, length = array.length; i < length; i++) {
|
21348 | if (formatTokenFunctions[array[i]]) {
|
21349 | array[i] = formatTokenFunctions[array[i]];
|
21350 | } else {
|
21351 | array[i] = removeFormattingTokens(array[i]);
|
21352 | }
|
21353 | }
|
21354 |
|
21355 | return function (mom) {
|
21356 | var output = '',
|
21357 | i;
|
21358 |
|
21359 | for (i = 0; i < length; i++) {
|
21360 | output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
|
21361 | }
|
21362 |
|
21363 | return output;
|
21364 | };
|
21365 | }
|
21366 |
|
21367 |
|
21368 | function formatMoment(m, format) {
|
21369 | if (!m.isValid()) {
|
21370 | return m.localeData().invalidDate();
|
21371 | }
|
21372 |
|
21373 | format = expandFormat(format, m.localeData());
|
21374 | formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
|
21375 | return formatFunctions[format](m);
|
21376 | }
|
21377 |
|
21378 | function expandFormat(format, locale) {
|
21379 | var i = 5;
|
21380 |
|
21381 | function replaceLongDateFormatTokens(input) {
|
21382 | return locale.longDateFormat(input) || input;
|
21383 | }
|
21384 |
|
21385 | localFormattingTokens.lastIndex = 0;
|
21386 |
|
21387 | while (i >= 0 && localFormattingTokens.test(format)) {
|
21388 | format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
21389 | localFormattingTokens.lastIndex = 0;
|
21390 | i -= 1;
|
21391 | }
|
21392 |
|
21393 | return format;
|
21394 | }
|
21395 |
|
21396 | var match1 = /\d/;
|
21397 |
|
21398 | var match2 = /\d\d/;
|
21399 |
|
21400 | var match3 = /\d{3}/;
|
21401 |
|
21402 | var match4 = /\d{4}/;
|
21403 |
|
21404 | var match6 = /[+-]?\d{6}/;
|
21405 |
|
21406 | var match1to2 = /\d\d?/;
|
21407 |
|
21408 | var match3to4 = /\d\d\d\d?/;
|
21409 |
|
21410 | var match5to6 = /\d\d\d\d\d\d?/;
|
21411 |
|
21412 | var match1to3 = /\d{1,3}/;
|
21413 |
|
21414 | var match1to4 = /\d{1,4}/;
|
21415 |
|
21416 | var match1to6 = /[+-]?\d{1,6}/;
|
21417 |
|
21418 | var matchUnsigned = /\d+/;
|
21419 |
|
21420 | var matchSigned = /[+-]?\d+/;
|
21421 |
|
21422 | var matchOffset = /Z|[+-]\d\d:?\d\d/gi;
|
21423 |
|
21424 | var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi;
|
21425 |
|
21426 | var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
21427 |
|
21428 |
|
21429 |
|
21430 | var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
|
21431 | var regexes = {};
|
21432 |
|
21433 | function addRegexToken(token, regex, strictRegex) {
|
21434 | regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
|
21435 | return isStrict && strictRegex ? strictRegex : regex;
|
21436 | };
|
21437 | }
|
21438 |
|
21439 | function getParseRegexForToken(token, config) {
|
21440 | if (!hasOwnProp(regexes, token)) {
|
21441 | return new RegExp(unescapeFormat(token));
|
21442 | }
|
21443 |
|
21444 | return regexes[token](config._strict, config._locale);
|
21445 | }
|
21446 |
|
21447 |
|
21448 | function unescapeFormat(s) {
|
21449 | return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
|
21450 | return p1 || p2 || p3 || p4;
|
21451 | }));
|
21452 | }
|
21453 |
|
21454 | function regexEscape(s) {
|
21455 | return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
21456 | }
|
21457 |
|
21458 | var tokens = {};
|
21459 |
|
21460 | function addParseToken(token, callback) {
|
21461 | var i,
|
21462 | func = callback;
|
21463 |
|
21464 | if (typeof token === 'string') {
|
21465 | token = [token];
|
21466 | }
|
21467 |
|
21468 | if (isNumber(callback)) {
|
21469 | func = function (input, array) {
|
21470 | array[callback] = toInt(input);
|
21471 | };
|
21472 | }
|
21473 |
|
21474 | for (i = 0; i < token.length; i++) {
|
21475 | tokens[token[i]] = func;
|
21476 | }
|
21477 | }
|
21478 |
|
21479 | function addWeekParseToken(token, callback) {
|
21480 | addParseToken(token, function (input, array, config, token) {
|
21481 | config._w = config._w || {};
|
21482 | callback(input, config._w, config, token);
|
21483 | });
|
21484 | }
|
21485 |
|
21486 | function addTimeToArrayFromToken(token, input, config) {
|
21487 | if (input != null && hasOwnProp(tokens, token)) {
|
21488 | tokens[token](input, config._a, config, token);
|
21489 | }
|
21490 | }
|
21491 |
|
21492 | var YEAR = 0;
|
21493 | var MONTH = 1;
|
21494 | var DATE = 2;
|
21495 | var HOUR = 3;
|
21496 | var MINUTE = 4;
|
21497 | var SECOND = 5;
|
21498 | var MILLISECOND = 6;
|
21499 | var WEEK = 7;
|
21500 | var WEEKDAY = 8;
|
21501 |
|
21502 | addFormatToken('Y', 0, 0, function () {
|
21503 | var y = this.year();
|
21504 | return y <= 9999 ? '' + y : '+' + y;
|
21505 | });
|
21506 | addFormatToken(0, ['YY', 2], 0, function () {
|
21507 | return this.year() % 100;
|
21508 | });
|
21509 | addFormatToken(0, ['YYYY', 4], 0, 'year');
|
21510 | addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
21511 | addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
21512 |
|
21513 | addUnitAlias('year', 'y');
|
21514 |
|
21515 | addUnitPriority('year', 1);
|
21516 |
|
21517 | addRegexToken('Y', matchSigned);
|
21518 | addRegexToken('YY', match1to2, match2);
|
21519 | addRegexToken('YYYY', match1to4, match4);
|
21520 | addRegexToken('YYYYY', match1to6, match6);
|
21521 | addRegexToken('YYYYYY', match1to6, match6);
|
21522 | addParseToken(['YYYYY', 'YYYYYY'], YEAR);
|
21523 | addParseToken('YYYY', function (input, array) {
|
21524 | array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
|
21525 | });
|
21526 | addParseToken('YY', function (input, array) {
|
21527 | array[YEAR] = hooks.parseTwoDigitYear(input);
|
21528 | });
|
21529 | addParseToken('Y', function (input, array) {
|
21530 | array[YEAR] = parseInt(input, 10);
|
21531 | });
|
21532 |
|
21533 | function daysInYear(year) {
|
21534 | return isLeapYear(year) ? 366 : 365;
|
21535 | }
|
21536 |
|
21537 | function isLeapYear(year) {
|
21538 | return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
21539 | }
|
21540 |
|
21541 |
|
21542 | hooks.parseTwoDigitYear = function (input) {
|
21543 | return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
21544 | };
|
21545 |
|
21546 |
|
21547 | var getSetYear = makeGetSet('FullYear', true);
|
21548 |
|
21549 | function getIsLeapYear() {
|
21550 | return isLeapYear(this.year());
|
21551 | }
|
21552 |
|
21553 | function makeGetSet(unit, keepTime) {
|
21554 | return function (value) {
|
21555 | if (value != null) {
|
21556 | set$1(this, unit, value);
|
21557 | hooks.updateOffset(this, keepTime);
|
21558 | return this;
|
21559 | } else {
|
21560 | return get(this, unit);
|
21561 | }
|
21562 | };
|
21563 | }
|
21564 |
|
21565 | function get(mom, unit) {
|
21566 | return mom.isValid() ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
|
21567 | }
|
21568 |
|
21569 | function set$1(mom, unit, value) {
|
21570 | if (mom.isValid() && !isNaN(value)) {
|
21571 | if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
|
21572 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
|
21573 | } else {
|
21574 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
21575 | }
|
21576 | }
|
21577 | }
|
21578 |
|
21579 |
|
21580 | function stringGet(units) {
|
21581 | units = normalizeUnits(units);
|
21582 |
|
21583 | if (isFunction(this[units])) {
|
21584 | return this[units]();
|
21585 | }
|
21586 |
|
21587 | return this;
|
21588 | }
|
21589 |
|
21590 | function stringSet(units, value) {
|
21591 | if (typeof units === 'object') {
|
21592 | units = normalizeObjectUnits(units);
|
21593 | var prioritized = getPrioritizedUnits(units);
|
21594 |
|
21595 | for (var i = 0; i < prioritized.length; i++) {
|
21596 | this[prioritized[i].unit](units[prioritized[i].unit]);
|
21597 | }
|
21598 | } else {
|
21599 | units = normalizeUnits(units);
|
21600 |
|
21601 | if (isFunction(this[units])) {
|
21602 | return this[units](value);
|
21603 | }
|
21604 | }
|
21605 |
|
21606 | return this;
|
21607 | }
|
21608 |
|
21609 | function mod(n, x) {
|
21610 | return (n % x + x) % x;
|
21611 | }
|
21612 |
|
21613 | var indexOf;
|
21614 |
|
21615 | if (Array.prototype.indexOf) {
|
21616 | indexOf = Array.prototype.indexOf;
|
21617 | } else {
|
21618 | indexOf = function (o) {
|
21619 |
|
21620 | var i;
|
21621 |
|
21622 | for (i = 0; i < this.length; ++i) {
|
21623 | if (this[i] === o) {
|
21624 | return i;
|
21625 | }
|
21626 | }
|
21627 |
|
21628 | return -1;
|
21629 | };
|
21630 | }
|
21631 |
|
21632 | function daysInMonth(year, month) {
|
21633 | if (isNaN(year) || isNaN(month)) {
|
21634 | return NaN;
|
21635 | }
|
21636 |
|
21637 | var modMonth = mod(month, 12);
|
21638 | year += (month - modMonth) / 12;
|
21639 | return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - modMonth % 7 % 2;
|
21640 | }
|
21641 |
|
21642 |
|
21643 | addFormatToken('M', ['MM', 2], 'Mo', function () {
|
21644 | return this.month() + 1;
|
21645 | });
|
21646 | addFormatToken('MMM', 0, 0, function (format) {
|
21647 | return this.localeData().monthsShort(this, format);
|
21648 | });
|
21649 | addFormatToken('MMMM', 0, 0, function (format) {
|
21650 | return this.localeData().months(this, format);
|
21651 | });
|
21652 |
|
21653 | addUnitAlias('month', 'M');
|
21654 |
|
21655 | addUnitPriority('month', 8);
|
21656 |
|
21657 | addRegexToken('M', match1to2);
|
21658 | addRegexToken('MM', match1to2, match2);
|
21659 | addRegexToken('MMM', function (isStrict, locale) {
|
21660 | return locale.monthsShortRegex(isStrict);
|
21661 | });
|
21662 | addRegexToken('MMMM', function (isStrict, locale) {
|
21663 | return locale.monthsRegex(isStrict);
|
21664 | });
|
21665 | addParseToken(['M', 'MM'], function (input, array) {
|
21666 | array[MONTH] = toInt(input) - 1;
|
21667 | });
|
21668 | addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
|
21669 | var month = config._locale.monthsParse(input, token, config._strict);
|
21670 |
|
21671 |
|
21672 | if (month != null) {
|
21673 | array[MONTH] = month;
|
21674 | } else {
|
21675 | getParsingFlags(config).invalidMonth = input;
|
21676 | }
|
21677 | });
|
21678 |
|
21679 | var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
|
21680 | var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
21681 |
|
21682 | function localeMonths(m, format) {
|
21683 | if (!m) {
|
21684 | return isArray(this._months) ? this._months : this._months['standalone'];
|
21685 | }
|
21686 |
|
21687 | return isArray(this._months) ? this._months[m.month()] : this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
|
21688 | }
|
21689 |
|
21690 | var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
21691 |
|
21692 | function localeMonthsShort(m, format) {
|
21693 | if (!m) {
|
21694 | return isArray(this._monthsShort) ? this._monthsShort : this._monthsShort['standalone'];
|
21695 | }
|
21696 |
|
21697 | return isArray(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
21698 | }
|
21699 |
|
21700 | function handleStrictParse(monthName, format, strict) {
|
21701 | var i,
|
21702 | ii,
|
21703 | mom,
|
21704 | llc = monthName.toLocaleLowerCase();
|
21705 |
|
21706 | if (!this._monthsParse) {
|
21707 |
|
21708 | this._monthsParse = [];
|
21709 | this._longMonthsParse = [];
|
21710 | this._shortMonthsParse = [];
|
21711 |
|
21712 | for (i = 0; i < 12; ++i) {
|
21713 | mom = createUTC([2000, i]);
|
21714 | this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
21715 | this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
21716 | }
|
21717 | }
|
21718 |
|
21719 | if (strict) {
|
21720 | if (format === 'MMM') {
|
21721 | ii = indexOf.call(this._shortMonthsParse, llc);
|
21722 | return ii !== -1 ? ii : null;
|
21723 | } else {
|
21724 | ii = indexOf.call(this._longMonthsParse, llc);
|
21725 | return ii !== -1 ? ii : null;
|
21726 | }
|
21727 | } else {
|
21728 | if (format === 'MMM') {
|
21729 | ii = indexOf.call(this._shortMonthsParse, llc);
|
21730 |
|
21731 | if (ii !== -1) {
|
21732 | return ii;
|
21733 | }
|
21734 |
|
21735 | ii = indexOf.call(this._longMonthsParse, llc);
|
21736 | return ii !== -1 ? ii : null;
|
21737 | } else {
|
21738 | ii = indexOf.call(this._longMonthsParse, llc);
|
21739 |
|
21740 | if (ii !== -1) {
|
21741 | return ii;
|
21742 | }
|
21743 |
|
21744 | ii = indexOf.call(this._shortMonthsParse, llc);
|
21745 | return ii !== -1 ? ii : null;
|
21746 | }
|
21747 | }
|
21748 | }
|
21749 |
|
21750 | function localeMonthsParse(monthName, format, strict) {
|
21751 | var i, mom, regex;
|
21752 |
|
21753 | if (this._monthsParseExact) {
|
21754 | return handleStrictParse.call(this, monthName, format, strict);
|
21755 | }
|
21756 |
|
21757 | if (!this._monthsParse) {
|
21758 | this._monthsParse = [];
|
21759 | this._longMonthsParse = [];
|
21760 | this._shortMonthsParse = [];
|
21761 | }
|
21762 |
|
21763 |
|
21764 |
|
21765 |
|
21766 | for (i = 0; i < 12; i++) {
|
21767 |
|
21768 | mom = createUTC([2000, i]);
|
21769 |
|
21770 | if (strict && !this._longMonthsParse[i]) {
|
21771 | this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
21772 | this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
21773 | }
|
21774 |
|
21775 | if (!strict && !this._monthsParse[i]) {
|
21776 | regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
21777 | this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
21778 | }
|
21779 |
|
21780 |
|
21781 | if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
|
21782 | return i;
|
21783 | } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
|
21784 | return i;
|
21785 | } else if (!strict && this._monthsParse[i].test(monthName)) {
|
21786 | return i;
|
21787 | }
|
21788 | }
|
21789 | }
|
21790 |
|
21791 |
|
21792 | function setMonth(mom, value) {
|
21793 | var dayOfMonth;
|
21794 |
|
21795 | if (!mom.isValid()) {
|
21796 |
|
21797 | return mom;
|
21798 | }
|
21799 |
|
21800 | if (typeof value === 'string') {
|
21801 | if (/^\d+$/.test(value)) {
|
21802 | value = toInt(value);
|
21803 | } else {
|
21804 | value = mom.localeData().monthsParse(value);
|
21805 |
|
21806 | if (!isNumber(value)) {
|
21807 | return mom;
|
21808 | }
|
21809 | }
|
21810 | }
|
21811 |
|
21812 | dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
|
21813 |
|
21814 | mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
21815 |
|
21816 | return mom;
|
21817 | }
|
21818 |
|
21819 | function getSetMonth(value) {
|
21820 | if (value != null) {
|
21821 | setMonth(this, value);
|
21822 | hooks.updateOffset(this, true);
|
21823 | return this;
|
21824 | } else {
|
21825 | return get(this, 'Month');
|
21826 | }
|
21827 | }
|
21828 |
|
21829 | function getDaysInMonth() {
|
21830 | return daysInMonth(this.year(), this.month());
|
21831 | }
|
21832 |
|
21833 | var defaultMonthsShortRegex = matchWord;
|
21834 |
|
21835 | function monthsShortRegex(isStrict) {
|
21836 | if (this._monthsParseExact) {
|
21837 | if (!hasOwnProp(this, '_monthsRegex')) {
|
21838 | computeMonthsParse.call(this);
|
21839 | }
|
21840 |
|
21841 | if (isStrict) {
|
21842 | return this._monthsShortStrictRegex;
|
21843 | } else {
|
21844 | return this._monthsShortRegex;
|
21845 | }
|
21846 | } else {
|
21847 | if (!hasOwnProp(this, '_monthsShortRegex')) {
|
21848 | this._monthsShortRegex = defaultMonthsShortRegex;
|
21849 | }
|
21850 |
|
21851 | return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex;
|
21852 | }
|
21853 | }
|
21854 |
|
21855 | var defaultMonthsRegex = matchWord;
|
21856 |
|
21857 | function monthsRegex(isStrict) {
|
21858 | if (this._monthsParseExact) {
|
21859 | if (!hasOwnProp(this, '_monthsRegex')) {
|
21860 | computeMonthsParse.call(this);
|
21861 | }
|
21862 |
|
21863 | if (isStrict) {
|
21864 | return this._monthsStrictRegex;
|
21865 | } else {
|
21866 | return this._monthsRegex;
|
21867 | }
|
21868 | } else {
|
21869 | if (!hasOwnProp(this, '_monthsRegex')) {
|
21870 | this._monthsRegex = defaultMonthsRegex;
|
21871 | }
|
21872 |
|
21873 | return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex;
|
21874 | }
|
21875 | }
|
21876 |
|
21877 | function computeMonthsParse() {
|
21878 | function cmpLenRev(a, b) {
|
21879 | return b.length - a.length;
|
21880 | }
|
21881 |
|
21882 | var shortPieces = [],
|
21883 | longPieces = [],
|
21884 | mixedPieces = [],
|
21885 | i,
|
21886 | mom;
|
21887 |
|
21888 | for (i = 0; i < 12; i++) {
|
21889 |
|
21890 | mom = createUTC([2000, i]);
|
21891 | shortPieces.push(this.monthsShort(mom, ''));
|
21892 | longPieces.push(this.months(mom, ''));
|
21893 | mixedPieces.push(this.months(mom, ''));
|
21894 | mixedPieces.push(this.monthsShort(mom, ''));
|
21895 | }
|
21896 |
|
21897 |
|
21898 |
|
21899 | shortPieces.sort(cmpLenRev);
|
21900 | longPieces.sort(cmpLenRev);
|
21901 | mixedPieces.sort(cmpLenRev);
|
21902 |
|
21903 | for (i = 0; i < 12; i++) {
|
21904 | shortPieces[i] = regexEscape(shortPieces[i]);
|
21905 | longPieces[i] = regexEscape(longPieces[i]);
|
21906 | }
|
21907 |
|
21908 | for (i = 0; i < 24; i++) {
|
21909 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
21910 | }
|
21911 |
|
21912 | this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
21913 | this._monthsShortRegex = this._monthsRegex;
|
21914 | this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
21915 | this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
21916 | }
|
21917 |
|
21918 | function createDate(y, m, d, h, M, s, ms) {
|
21919 |
|
21920 |
|
21921 | var date;
|
21922 |
|
21923 | if (y < 100 && y >= 0) {
|
21924 |
|
21925 | date = new Date(y + 400, m, d, h, M, s, ms);
|
21926 |
|
21927 | if (isFinite(date.getFullYear())) {
|
21928 | date.setFullYear(y);
|
21929 | }
|
21930 | } else {
|
21931 | date = new Date(y, m, d, h, M, s, ms);
|
21932 | }
|
21933 |
|
21934 | return date;
|
21935 | }
|
21936 |
|
21937 | function createUTCDate(y) {
|
21938 | var date;
|
21939 |
|
21940 | if (y < 100 && y >= 0) {
|
21941 | var args = Array.prototype.slice.call(arguments);
|
21942 |
|
21943 | args[0] = y + 400;
|
21944 | date = new Date(Date.UTC.apply(null, args));
|
21945 |
|
21946 | if (isFinite(date.getUTCFullYear())) {
|
21947 | date.setUTCFullYear(y);
|
21948 | }
|
21949 | } else {
|
21950 | date = new Date(Date.UTC.apply(null, arguments));
|
21951 | }
|
21952 |
|
21953 | return date;
|
21954 | }
|
21955 |
|
21956 |
|
21957 | function firstWeekOffset(year, dow, doy) {
|
21958 | var
|
21959 | fwd = 7 + dow - doy,
|
21960 |
|
21961 | fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
|
21962 | return -fwdlw + fwd - 1;
|
21963 | }
|
21964 |
|
21965 |
|
21966 | function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
|
21967 | var localWeekday = (7 + weekday - dow) % 7,
|
21968 | weekOffset = firstWeekOffset(year, dow, doy),
|
21969 | dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
|
21970 | resYear,
|
21971 | resDayOfYear;
|
21972 |
|
21973 | if (dayOfYear <= 0) {
|
21974 | resYear = year - 1;
|
21975 | resDayOfYear = daysInYear(resYear) + dayOfYear;
|
21976 | } else if (dayOfYear > daysInYear(year)) {
|
21977 | resYear = year + 1;
|
21978 | resDayOfYear = dayOfYear - daysInYear(year);
|
21979 | } else {
|
21980 | resYear = year;
|
21981 | resDayOfYear = dayOfYear;
|
21982 | }
|
21983 |
|
21984 | return {
|
21985 | year: resYear,
|
21986 | dayOfYear: resDayOfYear
|
21987 | };
|
21988 | }
|
21989 |
|
21990 | function weekOfYear(mom, dow, doy) {
|
21991 | var weekOffset = firstWeekOffset(mom.year(), dow, doy),
|
21992 | week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
|
21993 | resWeek,
|
21994 | resYear;
|
21995 |
|
21996 | if (week < 1) {
|
21997 | resYear = mom.year() - 1;
|
21998 | resWeek = week + weeksInYear(resYear, dow, doy);
|
21999 | } else if (week > weeksInYear(mom.year(), dow, doy)) {
|
22000 | resWeek = week - weeksInYear(mom.year(), dow, doy);
|
22001 | resYear = mom.year() + 1;
|
22002 | } else {
|
22003 | resYear = mom.year();
|
22004 | resWeek = week;
|
22005 | }
|
22006 |
|
22007 | return {
|
22008 | week: resWeek,
|
22009 | year: resYear
|
22010 | };
|
22011 | }
|
22012 |
|
22013 | function weeksInYear(year, dow, doy) {
|
22014 | var weekOffset = firstWeekOffset(year, dow, doy),
|
22015 | weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
|
22016 | return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
|
22017 | }
|
22018 |
|
22019 |
|
22020 | addFormatToken('w', ['ww', 2], 'wo', 'week');
|
22021 | addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
22022 |
|
22023 | addUnitAlias('week', 'w');
|
22024 | addUnitAlias('isoWeek', 'W');
|
22025 |
|
22026 | addUnitPriority('week', 5);
|
22027 | addUnitPriority('isoWeek', 5);
|
22028 |
|
22029 | addRegexToken('w', match1to2);
|
22030 | addRegexToken('ww', match1to2, match2);
|
22031 | addRegexToken('W', match1to2);
|
22032 | addRegexToken('WW', match1to2, match2);
|
22033 | addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
22034 | week[token.substr(0, 1)] = toInt(input);
|
22035 | });
|
22036 |
|
22037 |
|
22038 | function localeWeek(mom) {
|
22039 | return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
22040 | }
|
22041 |
|
22042 | var defaultLocaleWeek = {
|
22043 | dow: 0,
|
22044 |
|
22045 | doy: 6
|
22046 |
|
22047 | };
|
22048 |
|
22049 | function localeFirstDayOfWeek() {
|
22050 | return this._week.dow;
|
22051 | }
|
22052 |
|
22053 | function localeFirstDayOfYear() {
|
22054 | return this._week.doy;
|
22055 | }
|
22056 |
|
22057 |
|
22058 | function getSetWeek(input) {
|
22059 | var week = this.localeData().week(this);
|
22060 | return input == null ? week : this.add((input - week) * 7, 'd');
|
22061 | }
|
22062 |
|
22063 | function getSetISOWeek(input) {
|
22064 | var week = weekOfYear(this, 1, 4).week;
|
22065 | return input == null ? week : this.add((input - week) * 7, 'd');
|
22066 | }
|
22067 |
|
22068 |
|
22069 | addFormatToken('d', 0, 'do', 'day');
|
22070 | addFormatToken('dd', 0, 0, function (format) {
|
22071 | return this.localeData().weekdaysMin(this, format);
|
22072 | });
|
22073 | addFormatToken('ddd', 0, 0, function (format) {
|
22074 | return this.localeData().weekdaysShort(this, format);
|
22075 | });
|
22076 | addFormatToken('dddd', 0, 0, function (format) {
|
22077 | return this.localeData().weekdays(this, format);
|
22078 | });
|
22079 | addFormatToken('e', 0, 0, 'weekday');
|
22080 | addFormatToken('E', 0, 0, 'isoWeekday');
|
22081 |
|
22082 | addUnitAlias('day', 'd');
|
22083 | addUnitAlias('weekday', 'e');
|
22084 | addUnitAlias('isoWeekday', 'E');
|
22085 |
|
22086 | addUnitPriority('day', 11);
|
22087 | addUnitPriority('weekday', 11);
|
22088 | addUnitPriority('isoWeekday', 11);
|
22089 |
|
22090 | addRegexToken('d', match1to2);
|
22091 | addRegexToken('e', match1to2);
|
22092 | addRegexToken('E', match1to2);
|
22093 | addRegexToken('dd', function (isStrict, locale) {
|
22094 | return locale.weekdaysMinRegex(isStrict);
|
22095 | });
|
22096 | addRegexToken('ddd', function (isStrict, locale) {
|
22097 | return locale.weekdaysShortRegex(isStrict);
|
22098 | });
|
22099 | addRegexToken('dddd', function (isStrict, locale) {
|
22100 | return locale.weekdaysRegex(isStrict);
|
22101 | });
|
22102 | addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
22103 | var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
22104 |
|
22105 |
|
22106 | if (weekday != null) {
|
22107 | week.d = weekday;
|
22108 | } else {
|
22109 | getParsingFlags(config).invalidWeekday = input;
|
22110 | }
|
22111 | });
|
22112 | addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
22113 | week[token] = toInt(input);
|
22114 | });
|
22115 |
|
22116 | function parseWeekday(input, locale) {
|
22117 | if (typeof input !== 'string') {
|
22118 | return input;
|
22119 | }
|
22120 |
|
22121 | if (!isNaN(input)) {
|
22122 | return parseInt(input, 10);
|
22123 | }
|
22124 |
|
22125 | input = locale.weekdaysParse(input);
|
22126 |
|
22127 | if (typeof input === 'number') {
|
22128 | return input;
|
22129 | }
|
22130 |
|
22131 | return null;
|
22132 | }
|
22133 |
|
22134 | function parseIsoWeekday(input, locale) {
|
22135 | if (typeof input === 'string') {
|
22136 | return locale.weekdaysParse(input) % 7 || 7;
|
22137 | }
|
22138 |
|
22139 | return isNaN(input) ? null : input;
|
22140 | }
|
22141 |
|
22142 |
|
22143 | function shiftWeekdays(ws, n) {
|
22144 | return ws.slice(n, 7).concat(ws.slice(0, n));
|
22145 | }
|
22146 |
|
22147 | var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
22148 |
|
22149 | function localeWeekdays(m, format) {
|
22150 | var weekdays = isArray(this._weekdays) ? this._weekdays : this._weekdays[m && m !== true && this._weekdays.isFormat.test(format) ? 'format' : 'standalone'];
|
22151 | return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays;
|
22152 | }
|
22153 |
|
22154 | var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
22155 |
|
22156 | function localeWeekdaysShort(m) {
|
22157 | return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
22158 | }
|
22159 |
|
22160 | var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
22161 |
|
22162 | function localeWeekdaysMin(m) {
|
22163 | return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
22164 | }
|
22165 |
|
22166 | function handleStrictParse$1(weekdayName, format, strict) {
|
22167 | var i,
|
22168 | ii,
|
22169 | mom,
|
22170 | llc = weekdayName.toLocaleLowerCase();
|
22171 |
|
22172 | if (!this._weekdaysParse) {
|
22173 | this._weekdaysParse = [];
|
22174 | this._shortWeekdaysParse = [];
|
22175 | this._minWeekdaysParse = [];
|
22176 |
|
22177 | for (i = 0; i < 7; ++i) {
|
22178 | mom = createUTC([2000, 1]).day(i);
|
22179 | this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
22180 | this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
22181 | this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
22182 | }
|
22183 | }
|
22184 |
|
22185 | if (strict) {
|
22186 | if (format === 'dddd') {
|
22187 | ii = indexOf.call(this._weekdaysParse, llc);
|
22188 | return ii !== -1 ? ii : null;
|
22189 | } else if (format === 'ddd') {
|
22190 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
22191 | return ii !== -1 ? ii : null;
|
22192 | } else {
|
22193 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
22194 | return ii !== -1 ? ii : null;
|
22195 | }
|
22196 | } else {
|
22197 | if (format === 'dddd') {
|
22198 | ii = indexOf.call(this._weekdaysParse, llc);
|
22199 |
|
22200 | if (ii !== -1) {
|
22201 | return ii;
|
22202 | }
|
22203 |
|
22204 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
22205 |
|
22206 | if (ii !== -1) {
|
22207 | return ii;
|
22208 | }
|
22209 |
|
22210 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
22211 | return ii !== -1 ? ii : null;
|
22212 | } else if (format === 'ddd') {
|
22213 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
22214 |
|
22215 | if (ii !== -1) {
|
22216 | return ii;
|
22217 | }
|
22218 |
|
22219 | ii = indexOf.call(this._weekdaysParse, llc);
|
22220 |
|
22221 | if (ii !== -1) {
|
22222 | return ii;
|
22223 | }
|
22224 |
|
22225 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
22226 | return ii !== -1 ? ii : null;
|
22227 | } else {
|
22228 | ii = indexOf.call(this._minWeekdaysParse, llc);
|
22229 |
|
22230 | if (ii !== -1) {
|
22231 | return ii;
|
22232 | }
|
22233 |
|
22234 | ii = indexOf.call(this._weekdaysParse, llc);
|
22235 |
|
22236 | if (ii !== -1) {
|
22237 | return ii;
|
22238 | }
|
22239 |
|
22240 | ii = indexOf.call(this._shortWeekdaysParse, llc);
|
22241 | return ii !== -1 ? ii : null;
|
22242 | }
|
22243 | }
|
22244 | }
|
22245 |
|
22246 | function localeWeekdaysParse(weekdayName, format, strict) {
|
22247 | var i, mom, regex;
|
22248 |
|
22249 | if (this._weekdaysParseExact) {
|
22250 | return handleStrictParse$1.call(this, weekdayName, format, strict);
|
22251 | }
|
22252 |
|
22253 | if (!this._weekdaysParse) {
|
22254 | this._weekdaysParse = [];
|
22255 | this._minWeekdaysParse = [];
|
22256 | this._shortWeekdaysParse = [];
|
22257 | this._fullWeekdaysParse = [];
|
22258 | }
|
22259 |
|
22260 | for (i = 0; i < 7; i++) {
|
22261 |
|
22262 | mom = createUTC([2000, 1]).day(i);
|
22263 |
|
22264 | if (strict && !this._fullWeekdaysParse[i]) {
|
22265 | this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
|
22266 | this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
|
22267 | this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
|
22268 | }
|
22269 |
|
22270 | if (!this._weekdaysParse[i]) {
|
22271 | regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
22272 | this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
22273 | }
|
22274 |
|
22275 |
|
22276 | if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
|
22277 | return i;
|
22278 | } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
|
22279 | return i;
|
22280 | } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
|
22281 | return i;
|
22282 | } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
|
22283 | return i;
|
22284 | }
|
22285 | }
|
22286 | }
|
22287 |
|
22288 |
|
22289 | function getSetDayOfWeek(input) {
|
22290 | if (!this.isValid()) {
|
22291 | return input != null ? this : NaN;
|
22292 | }
|
22293 |
|
22294 | var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
22295 |
|
22296 | if (input != null) {
|
22297 | input = parseWeekday(input, this.localeData());
|
22298 | return this.add(input - day, 'd');
|
22299 | } else {
|
22300 | return day;
|
22301 | }
|
22302 | }
|
22303 |
|
22304 | function getSetLocaleDayOfWeek(input) {
|
22305 | if (!this.isValid()) {
|
22306 | return input != null ? this : NaN;
|
22307 | }
|
22308 |
|
22309 | var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
22310 | return input == null ? weekday : this.add(input - weekday, 'd');
|
22311 | }
|
22312 |
|
22313 | function getSetISODayOfWeek(input) {
|
22314 | if (!this.isValid()) {
|
22315 | return input != null ? this : NaN;
|
22316 | }
|
22317 |
|
22318 |
|
22319 |
|
22320 |
|
22321 | if (input != null) {
|
22322 | var weekday = parseIsoWeekday(input, this.localeData());
|
22323 | return this.day(this.day() % 7 ? weekday : weekday - 7);
|
22324 | } else {
|
22325 | return this.day() || 7;
|
22326 | }
|
22327 | }
|
22328 |
|
22329 | var defaultWeekdaysRegex = matchWord;
|
22330 |
|
22331 | function weekdaysRegex(isStrict) {
|
22332 | if (this._weekdaysParseExact) {
|
22333 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
22334 | computeWeekdaysParse.call(this);
|
22335 | }
|
22336 |
|
22337 | if (isStrict) {
|
22338 | return this._weekdaysStrictRegex;
|
22339 | } else {
|
22340 | return this._weekdaysRegex;
|
22341 | }
|
22342 | } else {
|
22343 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
22344 | this._weekdaysRegex = defaultWeekdaysRegex;
|
22345 | }
|
22346 |
|
22347 | return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex;
|
22348 | }
|
22349 | }
|
22350 |
|
22351 | var defaultWeekdaysShortRegex = matchWord;
|
22352 |
|
22353 | function weekdaysShortRegex(isStrict) {
|
22354 | if (this._weekdaysParseExact) {
|
22355 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
22356 | computeWeekdaysParse.call(this);
|
22357 | }
|
22358 |
|
22359 | if (isStrict) {
|
22360 | return this._weekdaysShortStrictRegex;
|
22361 | } else {
|
22362 | return this._weekdaysShortRegex;
|
22363 | }
|
22364 | } else {
|
22365 | if (!hasOwnProp(this, '_weekdaysShortRegex')) {
|
22366 | this._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
22367 | }
|
22368 |
|
22369 | return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
22370 | }
|
22371 | }
|
22372 |
|
22373 | var defaultWeekdaysMinRegex = matchWord;
|
22374 |
|
22375 | function weekdaysMinRegex(isStrict) {
|
22376 | if (this._weekdaysParseExact) {
|
22377 | if (!hasOwnProp(this, '_weekdaysRegex')) {
|
22378 | computeWeekdaysParse.call(this);
|
22379 | }
|
22380 |
|
22381 | if (isStrict) {
|
22382 | return this._weekdaysMinStrictRegex;
|
22383 | } else {
|
22384 | return this._weekdaysMinRegex;
|
22385 | }
|
22386 | } else {
|
22387 | if (!hasOwnProp(this, '_weekdaysMinRegex')) {
|
22388 | this._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
22389 | }
|
22390 |
|
22391 | return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
|
22392 | }
|
22393 | }
|
22394 |
|
22395 | function computeWeekdaysParse() {
|
22396 | function cmpLenRev(a, b) {
|
22397 | return b.length - a.length;
|
22398 | }
|
22399 |
|
22400 | var minPieces = [],
|
22401 | shortPieces = [],
|
22402 | longPieces = [],
|
22403 | mixedPieces = [],
|
22404 | i,
|
22405 | mom,
|
22406 | minp,
|
22407 | shortp,
|
22408 | longp;
|
22409 |
|
22410 | for (i = 0; i < 7; i++) {
|
22411 |
|
22412 | mom = createUTC([2000, 1]).day(i);
|
22413 | minp = this.weekdaysMin(mom, '');
|
22414 | shortp = this.weekdaysShort(mom, '');
|
22415 | longp = this.weekdays(mom, '');
|
22416 | minPieces.push(minp);
|
22417 | shortPieces.push(shortp);
|
22418 | longPieces.push(longp);
|
22419 | mixedPieces.push(minp);
|
22420 | mixedPieces.push(shortp);
|
22421 | mixedPieces.push(longp);
|
22422 | }
|
22423 |
|
22424 |
|
22425 |
|
22426 | minPieces.sort(cmpLenRev);
|
22427 | shortPieces.sort(cmpLenRev);
|
22428 | longPieces.sort(cmpLenRev);
|
22429 | mixedPieces.sort(cmpLenRev);
|
22430 |
|
22431 | for (i = 0; i < 7; i++) {
|
22432 | shortPieces[i] = regexEscape(shortPieces[i]);
|
22433 | longPieces[i] = regexEscape(longPieces[i]);
|
22434 | mixedPieces[i] = regexEscape(mixedPieces[i]);
|
22435 | }
|
22436 |
|
22437 | this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
22438 | this._weekdaysShortRegex = this._weekdaysRegex;
|
22439 | this._weekdaysMinRegex = this._weekdaysRegex;
|
22440 | this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
22441 | this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
22442 | this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
|
22443 | }
|
22444 |
|
22445 |
|
22446 | function hFormat() {
|
22447 | return this.hours() % 12 || 12;
|
22448 | }
|
22449 |
|
22450 | function kFormat() {
|
22451 | return this.hours() || 24;
|
22452 | }
|
22453 |
|
22454 | addFormatToken('H', ['HH', 2], 0, 'hour');
|
22455 | addFormatToken('h', ['hh', 2], 0, hFormat);
|
22456 | addFormatToken('k', ['kk', 2], 0, kFormat);
|
22457 | addFormatToken('hmm', 0, 0, function () {
|
22458 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
22459 | });
|
22460 | addFormatToken('hmmss', 0, 0, function () {
|
22461 | return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
22462 | });
|
22463 | addFormatToken('Hmm', 0, 0, function () {
|
22464 | return '' + this.hours() + zeroFill(this.minutes(), 2);
|
22465 | });
|
22466 | addFormatToken('Hmmss', 0, 0, function () {
|
22467 | return '' + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
|
22468 | });
|
22469 |
|
22470 | function meridiem(token, lowercase) {
|
22471 | addFormatToken(token, 0, 0, function () {
|
22472 | return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
22473 | });
|
22474 | }
|
22475 |
|
22476 | meridiem('a', true);
|
22477 | meridiem('A', false);
|
22478 |
|
22479 | addUnitAlias('hour', 'h');
|
22480 |
|
22481 | addUnitPriority('hour', 13);
|
22482 |
|
22483 | function matchMeridiem(isStrict, locale) {
|
22484 | return locale._meridiemParse;
|
22485 | }
|
22486 |
|
22487 | addRegexToken('a', matchMeridiem);
|
22488 | addRegexToken('A', matchMeridiem);
|
22489 | addRegexToken('H', match1to2);
|
22490 | addRegexToken('h', match1to2);
|
22491 | addRegexToken('k', match1to2);
|
22492 | addRegexToken('HH', match1to2, match2);
|
22493 | addRegexToken('hh', match1to2, match2);
|
22494 | addRegexToken('kk', match1to2, match2);
|
22495 | addRegexToken('hmm', match3to4);
|
22496 | addRegexToken('hmmss', match5to6);
|
22497 | addRegexToken('Hmm', match3to4);
|
22498 | addRegexToken('Hmmss', match5to6);
|
22499 | addParseToken(['H', 'HH'], HOUR);
|
22500 | addParseToken(['k', 'kk'], function (input, array, config) {
|
22501 | var kInput = toInt(input);
|
22502 | array[HOUR] = kInput === 24 ? 0 : kInput;
|
22503 | });
|
22504 | addParseToken(['a', 'A'], function (input, array, config) {
|
22505 | config._isPm = config._locale.isPM(input);
|
22506 | config._meridiem = input;
|
22507 | });
|
22508 | addParseToken(['h', 'hh'], function (input, array, config) {
|
22509 | array[HOUR] = toInt(input);
|
22510 | getParsingFlags(config).bigHour = true;
|
22511 | });
|
22512 | addParseToken('hmm', function (input, array, config) {
|
22513 | var pos = input.length - 2;
|
22514 | array[HOUR] = toInt(input.substr(0, pos));
|
22515 | array[MINUTE] = toInt(input.substr(pos));
|
22516 | getParsingFlags(config).bigHour = true;
|
22517 | });
|
22518 | addParseToken('hmmss', function (input, array, config) {
|
22519 | var pos1 = input.length - 4;
|
22520 | var pos2 = input.length - 2;
|
22521 | array[HOUR] = toInt(input.substr(0, pos1));
|
22522 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
22523 | array[SECOND] = toInt(input.substr(pos2));
|
22524 | getParsingFlags(config).bigHour = true;
|
22525 | });
|
22526 | addParseToken('Hmm', function (input, array, config) {
|
22527 | var pos = input.length - 2;
|
22528 | array[HOUR] = toInt(input.substr(0, pos));
|
22529 | array[MINUTE] = toInt(input.substr(pos));
|
22530 | });
|
22531 | addParseToken('Hmmss', function (input, array, config) {
|
22532 | var pos1 = input.length - 4;
|
22533 | var pos2 = input.length - 2;
|
22534 | array[HOUR] = toInt(input.substr(0, pos1));
|
22535 | array[MINUTE] = toInt(input.substr(pos1, 2));
|
22536 | array[SECOND] = toInt(input.substr(pos2));
|
22537 | });
|
22538 |
|
22539 | function localeIsPM(input) {
|
22540 |
|
22541 |
|
22542 | return (input + '').toLowerCase().charAt(0) === 'p';
|
22543 | }
|
22544 |
|
22545 | var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
22546 |
|
22547 | function localeMeridiem(hours, minutes, isLower) {
|
22548 | if (hours > 11) {
|
22549 | return isLower ? 'pm' : 'PM';
|
22550 | } else {
|
22551 | return isLower ? 'am' : 'AM';
|
22552 | }
|
22553 | }
|
22554 |
|
22555 |
|
22556 |
|
22557 |
|
22558 |
|
22559 |
|
22560 | var getSetHour = makeGetSet('Hours', true);
|
22561 | var baseConfig = {
|
22562 | calendar: defaultCalendar,
|
22563 | longDateFormat: defaultLongDateFormat,
|
22564 | invalidDate: defaultInvalidDate,
|
22565 | ordinal: defaultOrdinal,
|
22566 | dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
|
22567 | relativeTime: defaultRelativeTime,
|
22568 | months: defaultLocaleMonths,
|
22569 | monthsShort: defaultLocaleMonthsShort,
|
22570 | week: defaultLocaleWeek,
|
22571 | weekdays: defaultLocaleWeekdays,
|
22572 | weekdaysMin: defaultLocaleWeekdaysMin,
|
22573 | weekdaysShort: defaultLocaleWeekdaysShort,
|
22574 | meridiemParse: defaultLocaleMeridiemParse
|
22575 | };
|
22576 |
|
22577 | var locales = {};
|
22578 | var localeFamilies = {};
|
22579 | var globalLocale;
|
22580 |
|
22581 | function normalizeLocale(key) {
|
22582 | return key ? key.toLowerCase().replace('_', '-') : key;
|
22583 | }
|
22584 |
|
22585 |
|
22586 |
|
22587 |
|
22588 | function chooseLocale(names) {
|
22589 | var i = 0,
|
22590 | j,
|
22591 | next,
|
22592 | locale,
|
22593 | split;
|
22594 |
|
22595 | while (i < names.length) {
|
22596 | split = normalizeLocale(names[i]).split('-');
|
22597 | j = split.length;
|
22598 | next = normalizeLocale(names[i + 1]);
|
22599 | next = next ? next.split('-') : null;
|
22600 |
|
22601 | while (j > 0) {
|
22602 | locale = loadLocale(split.slice(0, j).join('-'));
|
22603 |
|
22604 | if (locale) {
|
22605 | return locale;
|
22606 | }
|
22607 |
|
22608 | if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
22609 |
|
22610 | break;
|
22611 | }
|
22612 |
|
22613 | j--;
|
22614 | }
|
22615 |
|
22616 | i++;
|
22617 | }
|
22618 |
|
22619 | return globalLocale;
|
22620 | }
|
22621 |
|
22622 | function loadLocale(name) {
|
22623 | var oldLocale = null;
|
22624 |
|
22625 | if (!locales[name] && 'object' !== 'undefined' && module && module.exports) {
|
22626 | try {
|
22627 | oldLocale = globalLocale._abbr;
|
22628 | var aliasedRequire = commonjsRequire$1;
|
22629 | aliasedRequire('./locale/' + name);
|
22630 | getSetGlobalLocale(oldLocale);
|
22631 | } catch (e) {}
|
22632 | }
|
22633 |
|
22634 | return locales[name];
|
22635 | }
|
22636 |
|
22637 |
|
22638 |
|
22639 |
|
22640 | function getSetGlobalLocale(key, values) {
|
22641 | var data;
|
22642 |
|
22643 | if (key) {
|
22644 | if (isUndefined(values)) {
|
22645 | data = getLocale(key);
|
22646 | } else {
|
22647 | data = defineLocale(key, values);
|
22648 | }
|
22649 |
|
22650 | if (data) {
|
22651 |
|
22652 | globalLocale = data;
|
22653 | } else {
|
22654 | if (typeof console !== 'undefined' && console.warn) {
|
22655 |
|
22656 | console.warn('Locale ' + key + ' not found. Did you forget to load it?');
|
22657 | }
|
22658 | }
|
22659 | }
|
22660 |
|
22661 | return globalLocale._abbr;
|
22662 | }
|
22663 |
|
22664 | function defineLocale(name, config) {
|
22665 | if (config !== null) {
|
22666 | var locale,
|
22667 | parentConfig = baseConfig;
|
22668 | config.abbr = name;
|
22669 |
|
22670 | if (locales[name] != null) {
|
22671 | deprecateSimple('defineLocaleOverride', 'use moment.updateLocale(localeName, config) to change ' + 'an existing locale. moment.defineLocale(localeName, ' + 'config) should only be used for creating a new locale ' + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
|
22672 | parentConfig = locales[name]._config;
|
22673 | } else if (config.parentLocale != null) {
|
22674 | if (locales[config.parentLocale] != null) {
|
22675 | parentConfig = locales[config.parentLocale]._config;
|
22676 | } else {
|
22677 | locale = loadLocale(config.parentLocale);
|
22678 |
|
22679 | if (locale != null) {
|
22680 | parentConfig = locale._config;
|
22681 | } else {
|
22682 | if (!localeFamilies[config.parentLocale]) {
|
22683 | localeFamilies[config.parentLocale] = [];
|
22684 | }
|
22685 |
|
22686 | localeFamilies[config.parentLocale].push({
|
22687 | name: name,
|
22688 | config: config
|
22689 | });
|
22690 | return null;
|
22691 | }
|
22692 | }
|
22693 | }
|
22694 |
|
22695 | locales[name] = new Locale(mergeConfigs(parentConfig, config));
|
22696 |
|
22697 | if (localeFamilies[name]) {
|
22698 | localeFamilies[name].forEach(function (x) {
|
22699 | defineLocale(x.name, x.config);
|
22700 | });
|
22701 | }
|
22702 |
|
22703 |
|
22704 |
|
22705 |
|
22706 | getSetGlobalLocale(name);
|
22707 | return locales[name];
|
22708 | } else {
|
22709 |
|
22710 | delete locales[name];
|
22711 | return null;
|
22712 | }
|
22713 | }
|
22714 |
|
22715 | function updateLocale(name, config) {
|
22716 | if (config != null) {
|
22717 | var locale,
|
22718 | tmpLocale,
|
22719 | parentConfig = baseConfig;
|
22720 |
|
22721 | tmpLocale = loadLocale(name);
|
22722 |
|
22723 | if (tmpLocale != null) {
|
22724 | parentConfig = tmpLocale._config;
|
22725 | }
|
22726 |
|
22727 | config = mergeConfigs(parentConfig, config);
|
22728 | locale = new Locale(config);
|
22729 | locale.parentLocale = locales[name];
|
22730 | locales[name] = locale;
|
22731 |
|
22732 | getSetGlobalLocale(name);
|
22733 | } else {
|
22734 |
|
22735 | if (locales[name] != null) {
|
22736 | if (locales[name].parentLocale != null) {
|
22737 | locales[name] = locales[name].parentLocale;
|
22738 | } else if (locales[name] != null) {
|
22739 | delete locales[name];
|
22740 | }
|
22741 | }
|
22742 | }
|
22743 |
|
22744 | return locales[name];
|
22745 | }
|
22746 |
|
22747 |
|
22748 | function getLocale(key) {
|
22749 | var locale;
|
22750 |
|
22751 | if (key && key._locale && key._locale._abbr) {
|
22752 | key = key._locale._abbr;
|
22753 | }
|
22754 |
|
22755 | if (!key) {
|
22756 | return globalLocale;
|
22757 | }
|
22758 |
|
22759 | if (!isArray(key)) {
|
22760 |
|
22761 | locale = loadLocale(key);
|
22762 |
|
22763 | if (locale) {
|
22764 | return locale;
|
22765 | }
|
22766 |
|
22767 | key = [key];
|
22768 | }
|
22769 |
|
22770 | return chooseLocale(key);
|
22771 | }
|
22772 |
|
22773 | function listLocales() {
|
22774 | return keys(locales);
|
22775 | }
|
22776 |
|
22777 | function checkOverflow(m) {
|
22778 | var overflow;
|
22779 | var a = m._a;
|
22780 |
|
22781 | if (a && getParsingFlags(m).overflow === -2) {
|
22782 | overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1;
|
22783 |
|
22784 | if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
22785 | overflow = DATE;
|
22786 | }
|
22787 |
|
22788 | if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
|
22789 | overflow = WEEK;
|
22790 | }
|
22791 |
|
22792 | if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
|
22793 | overflow = WEEKDAY;
|
22794 | }
|
22795 |
|
22796 | getParsingFlags(m).overflow = overflow;
|
22797 | }
|
22798 |
|
22799 | return m;
|
22800 | }
|
22801 |
|
22802 |
|
22803 | function defaults(a, b, c) {
|
22804 | if (a != null) {
|
22805 | return a;
|
22806 | }
|
22807 |
|
22808 | if (b != null) {
|
22809 | return b;
|
22810 | }
|
22811 |
|
22812 | return c;
|
22813 | }
|
22814 |
|
22815 | function currentDateArray(config) {
|
22816 |
|
22817 | var nowValue = new Date(hooks.now());
|
22818 |
|
22819 | if (config._useUTC) {
|
22820 | return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
|
22821 | }
|
22822 |
|
22823 | return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
|
22824 | }
|
22825 |
|
22826 |
|
22827 |
|
22828 |
|
22829 |
|
22830 | function configFromArray(config) {
|
22831 | var i,
|
22832 | date,
|
22833 | input = [],
|
22834 | currentDate,
|
22835 | expectedWeekday,
|
22836 | yearToUse;
|
22837 |
|
22838 | if (config._d) {
|
22839 | return;
|
22840 | }
|
22841 |
|
22842 | currentDate = currentDateArray(config);
|
22843 |
|
22844 | if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
22845 | dayOfYearFromWeekInfo(config);
|
22846 | }
|
22847 |
|
22848 |
|
22849 | if (config._dayOfYear != null) {
|
22850 | yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
22851 |
|
22852 | if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
|
22853 | getParsingFlags(config)._overflowDayOfYear = true;
|
22854 | }
|
22855 |
|
22856 | date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
22857 | config._a[MONTH] = date.getUTCMonth();
|
22858 | config._a[DATE] = date.getUTCDate();
|
22859 | }
|
22860 |
|
22861 |
|
22862 |
|
22863 |
|
22864 |
|
22865 |
|
22866 | for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
22867 | config._a[i] = input[i] = currentDate[i];
|
22868 | }
|
22869 |
|
22870 |
|
22871 | for (; i < 7; i++) {
|
22872 | config._a[i] = input[i] = config._a[i] == null ? i === 2 ? 1 : 0 : config._a[i];
|
22873 | }
|
22874 |
|
22875 |
|
22876 | if (config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0) {
|
22877 | config._nextDay = true;
|
22878 | config._a[HOUR] = 0;
|
22879 | }
|
22880 |
|
22881 | config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
|
22882 | expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
|
22883 |
|
22884 |
|
22885 | if (config._tzm != null) {
|
22886 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
22887 | }
|
22888 |
|
22889 | if (config._nextDay) {
|
22890 | config._a[HOUR] = 24;
|
22891 | }
|
22892 |
|
22893 |
|
22894 | if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
|
22895 | getParsingFlags(config).weekdayMismatch = true;
|
22896 | }
|
22897 | }
|
22898 |
|
22899 | function dayOfYearFromWeekInfo(config) {
|
22900 | var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
|
22901 | w = config._w;
|
22902 |
|
22903 | if (w.GG != null || w.W != null || w.E != null) {
|
22904 | dow = 1;
|
22905 | doy = 4;
|
22906 |
|
22907 |
|
22908 |
|
22909 |
|
22910 | weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
|
22911 | week = defaults(w.W, 1);
|
22912 | weekday = defaults(w.E, 1);
|
22913 |
|
22914 | if (weekday < 1 || weekday > 7) {
|
22915 | weekdayOverflow = true;
|
22916 | }
|
22917 | } else {
|
22918 | dow = config._locale._week.dow;
|
22919 | doy = config._locale._week.doy;
|
22920 | var curWeek = weekOfYear(createLocal(), dow, doy);
|
22921 | weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
|
22922 |
|
22923 | week = defaults(w.w, curWeek.week);
|
22924 |
|
22925 | if (w.d != null) {
|
22926 |
|
22927 | weekday = w.d;
|
22928 |
|
22929 | if (weekday < 0 || weekday > 6) {
|
22930 | weekdayOverflow = true;
|
22931 | }
|
22932 | } else if (w.e != null) {
|
22933 |
|
22934 | weekday = w.e + dow;
|
22935 |
|
22936 | if (w.e < 0 || w.e > 6) {
|
22937 | weekdayOverflow = true;
|
22938 | }
|
22939 | } else {
|
22940 |
|
22941 | weekday = dow;
|
22942 | }
|
22943 | }
|
22944 |
|
22945 | if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
|
22946 | getParsingFlags(config)._overflowWeeks = true;
|
22947 | } else if (weekdayOverflow != null) {
|
22948 | getParsingFlags(config)._overflowWeekday = true;
|
22949 | } else {
|
22950 | temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
|
22951 | config._a[YEAR] = temp.year;
|
22952 | config._dayOfYear = temp.dayOfYear;
|
22953 | }
|
22954 | }
|
22955 |
|
22956 |
|
22957 |
|
22958 | var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
|
22959 | var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
|
22960 | var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
|
22961 | var isoDates = [['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], ['GGGG-[W]WW', /\d{4}-W\d\d/, false], ['YYYY-DDD', /\d{4}-\d{3}/], ['YYYY-MM', /\d{4}-\d\d/, false], ['YYYYYYMMDD', /[+-]\d{10}/], ['YYYYMMDD', /\d{8}/],
|
22962 | ['GGGG[W]WWE', /\d{4}W\d{3}/], ['GGGG[W]WW', /\d{4}W\d{2}/, false], ['YYYYDDD', /\d{7}/]];
|
22963 |
|
22964 | var isoTimes = [['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], ['HH:mm:ss', /\d\d:\d\d:\d\d/], ['HH:mm', /\d\d:\d\d/], ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], ['HHmmss', /\d\d\d\d\d\d/], ['HHmm', /\d\d\d\d/], ['HH', /\d\d/]];
|
22965 | var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
|
22966 |
|
22967 | function configFromISO(config) {
|
22968 | var i,
|
22969 | l,
|
22970 | string = config._i,
|
22971 | match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
|
22972 | allowTime,
|
22973 | dateFormat,
|
22974 | timeFormat,
|
22975 | tzFormat;
|
22976 |
|
22977 | if (match) {
|
22978 | getParsingFlags(config).iso = true;
|
22979 |
|
22980 | for (i = 0, l = isoDates.length; i < l; i++) {
|
22981 | if (isoDates[i][1].exec(match[1])) {
|
22982 | dateFormat = isoDates[i][0];
|
22983 | allowTime = isoDates[i][2] !== false;
|
22984 | break;
|
22985 | }
|
22986 | }
|
22987 |
|
22988 | if (dateFormat == null) {
|
22989 | config._isValid = false;
|
22990 | return;
|
22991 | }
|
22992 |
|
22993 | if (match[3]) {
|
22994 | for (i = 0, l = isoTimes.length; i < l; i++) {
|
22995 | if (isoTimes[i][1].exec(match[3])) {
|
22996 |
|
22997 | timeFormat = (match[2] || ' ') + isoTimes[i][0];
|
22998 | break;
|
22999 | }
|
23000 | }
|
23001 |
|
23002 | if (timeFormat == null) {
|
23003 | config._isValid = false;
|
23004 | return;
|
23005 | }
|
23006 | }
|
23007 |
|
23008 | if (!allowTime && timeFormat != null) {
|
23009 | config._isValid = false;
|
23010 | return;
|
23011 | }
|
23012 |
|
23013 | if (match[4]) {
|
23014 | if (tzRegex.exec(match[4])) {
|
23015 | tzFormat = 'Z';
|
23016 | } else {
|
23017 | config._isValid = false;
|
23018 | return;
|
23019 | }
|
23020 | }
|
23021 |
|
23022 | config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
|
23023 | configFromStringAndFormat(config);
|
23024 | } else {
|
23025 | config._isValid = false;
|
23026 | }
|
23027 | }
|
23028 |
|
23029 |
|
23030 | var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
|
23031 |
|
23032 | function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
23033 | var result = [untruncateYear(yearStr), defaultLocaleMonthsShort.indexOf(monthStr), parseInt(dayStr, 10), parseInt(hourStr, 10), parseInt(minuteStr, 10)];
|
23034 |
|
23035 | if (secondStr) {
|
23036 | result.push(parseInt(secondStr, 10));
|
23037 | }
|
23038 |
|
23039 | return result;
|
23040 | }
|
23041 |
|
23042 | function untruncateYear(yearStr) {
|
23043 | var year = parseInt(yearStr, 10);
|
23044 |
|
23045 | if (year <= 49) {
|
23046 | return 2000 + year;
|
23047 | } else if (year <= 999) {
|
23048 | return 1900 + year;
|
23049 | }
|
23050 |
|
23051 | return year;
|
23052 | }
|
23053 |
|
23054 | function preprocessRFC2822(s) {
|
23055 |
|
23056 | return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
23057 | }
|
23058 |
|
23059 | function checkWeekday(weekdayStr, parsedInput, config) {
|
23060 | if (weekdayStr) {
|
23061 |
|
23062 | var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
|
23063 | weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
|
23064 |
|
23065 | if (weekdayProvided !== weekdayActual) {
|
23066 | getParsingFlags(config).weekdayMismatch = true;
|
23067 | config._isValid = false;
|
23068 | return false;
|
23069 | }
|
23070 | }
|
23071 |
|
23072 | return true;
|
23073 | }
|
23074 |
|
23075 | var obsOffsets = {
|
23076 | UT: 0,
|
23077 | GMT: 0,
|
23078 | EDT: -4 * 60,
|
23079 | EST: -5 * 60,
|
23080 | CDT: -5 * 60,
|
23081 | CST: -6 * 60,
|
23082 | MDT: -6 * 60,
|
23083 | MST: -7 * 60,
|
23084 | PDT: -7 * 60,
|
23085 | PST: -8 * 60
|
23086 | };
|
23087 |
|
23088 | function calculateOffset(obsOffset, militaryOffset, numOffset) {
|
23089 | if (obsOffset) {
|
23090 | return obsOffsets[obsOffset];
|
23091 | } else if (militaryOffset) {
|
23092 |
|
23093 | return 0;
|
23094 | } else {
|
23095 | var hm = parseInt(numOffset, 10);
|
23096 | var m = hm % 100,
|
23097 | h = (hm - m) / 100;
|
23098 | return h * 60 + m;
|
23099 | }
|
23100 | }
|
23101 |
|
23102 |
|
23103 | function configFromRFC2822(config) {
|
23104 | var match = rfc2822.exec(preprocessRFC2822(config._i));
|
23105 |
|
23106 | if (match) {
|
23107 | var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
|
23108 |
|
23109 | if (!checkWeekday(match[1], parsedArray, config)) {
|
23110 | return;
|
23111 | }
|
23112 |
|
23113 | config._a = parsedArray;
|
23114 | config._tzm = calculateOffset(match[8], match[9], match[10]);
|
23115 | config._d = createUTCDate.apply(null, config._a);
|
23116 |
|
23117 | config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
23118 |
|
23119 | getParsingFlags(config).rfc2822 = true;
|
23120 | } else {
|
23121 | config._isValid = false;
|
23122 | }
|
23123 | }
|
23124 |
|
23125 |
|
23126 | function configFromString(config) {
|
23127 | var matched = aspNetJsonRegex.exec(config._i);
|
23128 |
|
23129 | if (matched !== null) {
|
23130 | config._d = new Date(+matched[1]);
|
23131 | return;
|
23132 | }
|
23133 |
|
23134 | configFromISO(config);
|
23135 |
|
23136 | if (config._isValid === false) {
|
23137 | delete config._isValid;
|
23138 | } else {
|
23139 | return;
|
23140 | }
|
23141 |
|
23142 | configFromRFC2822(config);
|
23143 |
|
23144 | if (config._isValid === false) {
|
23145 | delete config._isValid;
|
23146 | } else {
|
23147 | return;
|
23148 | }
|
23149 |
|
23150 |
|
23151 | hooks.createFromInputFallback(config);
|
23152 | }
|
23153 |
|
23154 | hooks.createFromInputFallback = deprecate('value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 'discouraged and will be removed in an upcoming major release. Please refer to ' + 'http://momentjs.com/guides/#/warnings/js-date/ for more info.', function (config) {
|
23155 | config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
23156 | });
|
23157 |
|
23158 | hooks.ISO_8601 = function () {};
|
23159 |
|
23160 |
|
23161 | hooks.RFC_2822 = function () {};
|
23162 |
|
23163 |
|
23164 | function configFromStringAndFormat(config) {
|
23165 |
|
23166 | if (config._f === hooks.ISO_8601) {
|
23167 | configFromISO(config);
|
23168 | return;
|
23169 | }
|
23170 |
|
23171 | if (config._f === hooks.RFC_2822) {
|
23172 | configFromRFC2822(config);
|
23173 | return;
|
23174 | }
|
23175 |
|
23176 | config._a = [];
|
23177 | getParsingFlags(config).empty = true;
|
23178 |
|
23179 | var string = '' + config._i,
|
23180 | i,
|
23181 | parsedInput,
|
23182 | tokens,
|
23183 | token,
|
23184 | skipped,
|
23185 | stringLength = string.length,
|
23186 | totalParsedInputLength = 0;
|
23187 | tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
|
23188 |
|
23189 | for (i = 0; i < tokens.length; i++) {
|
23190 | token = tokens[i];
|
23191 | parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
|
23192 |
|
23193 |
|
23194 | if (parsedInput) {
|
23195 | skipped = string.substr(0, string.indexOf(parsedInput));
|
23196 |
|
23197 | if (skipped.length > 0) {
|
23198 | getParsingFlags(config).unusedInput.push(skipped);
|
23199 | }
|
23200 |
|
23201 | string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
23202 | totalParsedInputLength += parsedInput.length;
|
23203 | }
|
23204 |
|
23205 |
|
23206 | if (formatTokenFunctions[token]) {
|
23207 | if (parsedInput) {
|
23208 | getParsingFlags(config).empty = false;
|
23209 | } else {
|
23210 | getParsingFlags(config).unusedTokens.push(token);
|
23211 | }
|
23212 |
|
23213 | addTimeToArrayFromToken(token, parsedInput, config);
|
23214 | } else if (config._strict && !parsedInput) {
|
23215 | getParsingFlags(config).unusedTokens.push(token);
|
23216 | }
|
23217 | }
|
23218 |
|
23219 |
|
23220 | getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
23221 |
|
23222 | if (string.length > 0) {
|
23223 | getParsingFlags(config).unusedInput.push(string);
|
23224 | }
|
23225 |
|
23226 |
|
23227 | if (config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0) {
|
23228 | getParsingFlags(config).bigHour = undefined;
|
23229 | }
|
23230 |
|
23231 | getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
23232 | getParsingFlags(config).meridiem = config._meridiem;
|
23233 |
|
23234 | config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
23235 | configFromArray(config);
|
23236 | checkOverflow(config);
|
23237 | }
|
23238 |
|
23239 | function meridiemFixWrap(locale, hour, meridiem) {
|
23240 | var isPm;
|
23241 |
|
23242 | if (meridiem == null) {
|
23243 |
|
23244 | return hour;
|
23245 | }
|
23246 |
|
23247 | if (locale.meridiemHour != null) {
|
23248 | return locale.meridiemHour(hour, meridiem);
|
23249 | } else if (locale.isPM != null) {
|
23250 |
|
23251 | isPm = locale.isPM(meridiem);
|
23252 |
|
23253 | if (isPm && hour < 12) {
|
23254 | hour += 12;
|
23255 | }
|
23256 |
|
23257 | if (!isPm && hour === 12) {
|
23258 | hour = 0;
|
23259 | }
|
23260 |
|
23261 | return hour;
|
23262 | } else {
|
23263 |
|
23264 | return hour;
|
23265 | }
|
23266 | }
|
23267 |
|
23268 |
|
23269 | function configFromStringAndArray(config) {
|
23270 | var tempConfig, bestMoment, scoreToBeat, i, currentScore;
|
23271 |
|
23272 | if (config._f.length === 0) {
|
23273 | getParsingFlags(config).invalidFormat = true;
|
23274 | config._d = new Date(NaN);
|
23275 | return;
|
23276 | }
|
23277 |
|
23278 | for (i = 0; i < config._f.length; i++) {
|
23279 | currentScore = 0;
|
23280 | tempConfig = copyConfig({}, config);
|
23281 |
|
23282 | if (config._useUTC != null) {
|
23283 | tempConfig._useUTC = config._useUTC;
|
23284 | }
|
23285 |
|
23286 | tempConfig._f = config._f[i];
|
23287 | configFromStringAndFormat(tempConfig);
|
23288 |
|
23289 | if (!isValid(tempConfig)) {
|
23290 | continue;
|
23291 | }
|
23292 |
|
23293 |
|
23294 | currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
23295 |
|
23296 | currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
23297 | getParsingFlags(tempConfig).score = currentScore;
|
23298 |
|
23299 | if (scoreToBeat == null || currentScore < scoreToBeat) {
|
23300 | scoreToBeat = currentScore;
|
23301 | bestMoment = tempConfig;
|
23302 | }
|
23303 | }
|
23304 |
|
23305 | extend(config, bestMoment || tempConfig);
|
23306 | }
|
23307 |
|
23308 | function configFromObject(config) {
|
23309 | if (config._d) {
|
23310 | return;
|
23311 | }
|
23312 |
|
23313 | var i = normalizeObjectUnits(config._i);
|
23314 | config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
|
23315 | return obj && parseInt(obj, 10);
|
23316 | });
|
23317 | configFromArray(config);
|
23318 | }
|
23319 |
|
23320 | function createFromConfig(config) {
|
23321 | var res = new Moment(checkOverflow(prepareConfig(config)));
|
23322 |
|
23323 | if (res._nextDay) {
|
23324 |
|
23325 | res.add(1, 'd');
|
23326 | res._nextDay = undefined;
|
23327 | }
|
23328 |
|
23329 | return res;
|
23330 | }
|
23331 |
|
23332 | function prepareConfig(config) {
|
23333 | var input = config._i,
|
23334 | format = config._f;
|
23335 | config._locale = config._locale || getLocale(config._l);
|
23336 |
|
23337 | if (input === null || format === undefined && input === '') {
|
23338 | return createInvalid({
|
23339 | nullInput: true
|
23340 | });
|
23341 | }
|
23342 |
|
23343 | if (typeof input === 'string') {
|
23344 | config._i = input = config._locale.preparse(input);
|
23345 | }
|
23346 |
|
23347 | if (isMoment(input)) {
|
23348 | return new Moment(checkOverflow(input));
|
23349 | } else if (isDate(input)) {
|
23350 | config._d = input;
|
23351 | } else if (isArray(format)) {
|
23352 | configFromStringAndArray(config);
|
23353 | } else if (format) {
|
23354 | configFromStringAndFormat(config);
|
23355 | } else {
|
23356 | configFromInput(config);
|
23357 | }
|
23358 |
|
23359 | if (!isValid(config)) {
|
23360 | config._d = null;
|
23361 | }
|
23362 |
|
23363 | return config;
|
23364 | }
|
23365 |
|
23366 | function configFromInput(config) {
|
23367 | var input = config._i;
|
23368 |
|
23369 | if (isUndefined(input)) {
|
23370 | config._d = new Date(hooks.now());
|
23371 | } else if (isDate(input)) {
|
23372 | config._d = new Date(input.valueOf());
|
23373 | } else if (typeof input === 'string') {
|
23374 | configFromString(config);
|
23375 | } else if (isArray(input)) {
|
23376 | config._a = map(input.slice(0), function (obj) {
|
23377 | return parseInt(obj, 10);
|
23378 | });
|
23379 | configFromArray(config);
|
23380 | } else if (isObject(input)) {
|
23381 | configFromObject(config);
|
23382 | } else if (isNumber(input)) {
|
23383 |
|
23384 | config._d = new Date(input);
|
23385 | } else {
|
23386 | hooks.createFromInputFallback(config);
|
23387 | }
|
23388 | }
|
23389 |
|
23390 | function createLocalOrUTC(input, format, locale, strict, isUTC) {
|
23391 | var c = {};
|
23392 |
|
23393 | if (locale === true || locale === false) {
|
23394 | strict = locale;
|
23395 | locale = undefined;
|
23396 | }
|
23397 |
|
23398 | if (isObject(input) && isObjectEmpty(input) || isArray(input) && input.length === 0) {
|
23399 | input = undefined;
|
23400 | }
|
23401 |
|
23402 |
|
23403 |
|
23404 | c._isAMomentObject = true;
|
23405 | c._useUTC = c._isUTC = isUTC;
|
23406 | c._l = locale;
|
23407 | c._i = input;
|
23408 | c._f = format;
|
23409 | c._strict = strict;
|
23410 | return createFromConfig(c);
|
23411 | }
|
23412 |
|
23413 | function createLocal(input, format, locale, strict) {
|
23414 | return createLocalOrUTC(input, format, locale, strict, false);
|
23415 | }
|
23416 |
|
23417 | var prototypeMin = deprecate('moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
23418 | var other = createLocal.apply(null, arguments);
|
23419 |
|
23420 | if (this.isValid() && other.isValid()) {
|
23421 | return other < this ? this : other;
|
23422 | } else {
|
23423 | return createInvalid();
|
23424 | }
|
23425 | });
|
23426 | var prototypeMax = deprecate('moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', function () {
|
23427 | var other = createLocal.apply(null, arguments);
|
23428 |
|
23429 | if (this.isValid() && other.isValid()) {
|
23430 | return other > this ? this : other;
|
23431 | } else {
|
23432 | return createInvalid();
|
23433 | }
|
23434 | });
|
23435 |
|
23436 |
|
23437 |
|
23438 |
|
23439 |
|
23440 | function pickBy(fn, moments) {
|
23441 | var res, i;
|
23442 |
|
23443 | if (moments.length === 1 && isArray(moments[0])) {
|
23444 | moments = moments[0];
|
23445 | }
|
23446 |
|
23447 | if (!moments.length) {
|
23448 | return createLocal();
|
23449 | }
|
23450 |
|
23451 | res = moments[0];
|
23452 |
|
23453 | for (i = 1; i < moments.length; ++i) {
|
23454 | if (!moments[i].isValid() || moments[i][fn](res)) {
|
23455 | res = moments[i];
|
23456 | }
|
23457 | }
|
23458 |
|
23459 | return res;
|
23460 | }
|
23461 |
|
23462 |
|
23463 | function min() {
|
23464 | var args = [].slice.call(arguments, 0);
|
23465 | return pickBy('isBefore', args);
|
23466 | }
|
23467 |
|
23468 | function max() {
|
23469 | var args = [].slice.call(arguments, 0);
|
23470 | return pickBy('isAfter', args);
|
23471 | }
|
23472 |
|
23473 | var now = function () {
|
23474 | return Date.now ? Date.now() : +new Date();
|
23475 | };
|
23476 |
|
23477 | var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
|
23478 |
|
23479 | function isDurationValid(m) {
|
23480 | for (var key in m) {
|
23481 | if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
|
23482 | return false;
|
23483 | }
|
23484 | }
|
23485 |
|
23486 | var unitHasDecimal = false;
|
23487 |
|
23488 | for (var i = 0; i < ordering.length; ++i) {
|
23489 | if (m[ordering[i]]) {
|
23490 | if (unitHasDecimal) {
|
23491 | return false;
|
23492 | }
|
23493 |
|
23494 | if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
|
23495 | unitHasDecimal = true;
|
23496 | }
|
23497 | }
|
23498 | }
|
23499 |
|
23500 | return true;
|
23501 | }
|
23502 |
|
23503 | function isValid$1() {
|
23504 | return this._isValid;
|
23505 | }
|
23506 |
|
23507 | function createInvalid$1() {
|
23508 | return createDuration(NaN);
|
23509 | }
|
23510 |
|
23511 | function Duration(duration) {
|
23512 | var normalizedInput = normalizeObjectUnits(duration),
|
23513 | years = normalizedInput.year || 0,
|
23514 | quarters = normalizedInput.quarter || 0,
|
23515 | months = normalizedInput.month || 0,
|
23516 | weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
23517 | days = normalizedInput.day || 0,
|
23518 | hours = normalizedInput.hour || 0,
|
23519 | minutes = normalizedInput.minute || 0,
|
23520 | seconds = normalizedInput.second || 0,
|
23521 | milliseconds = normalizedInput.millisecond || 0;
|
23522 | this._isValid = isDurationValid(normalizedInput);
|
23523 |
|
23524 | this._milliseconds = +milliseconds + seconds * 1e3 +
|
23525 | minutes * 6e4 +
|
23526 | hours * 1000 * 60 * 60;
|
23527 |
|
23528 |
|
23529 |
|
23530 | this._days = +days + weeks * 7;
|
23531 |
|
23532 |
|
23533 |
|
23534 | this._months = +months + quarters * 3 + years * 12;
|
23535 | this._data = {};
|
23536 | this._locale = getLocale();
|
23537 |
|
23538 | this._bubble();
|
23539 | }
|
23540 |
|
23541 | function isDuration(obj) {
|
23542 | return obj instanceof Duration;
|
23543 | }
|
23544 |
|
23545 | function absRound(number) {
|
23546 | if (number < 0) {
|
23547 | return Math.round(-1 * number) * -1;
|
23548 | } else {
|
23549 | return Math.round(number);
|
23550 | }
|
23551 | }
|
23552 |
|
23553 |
|
23554 | function offset(token, separator) {
|
23555 | addFormatToken(token, 0, 0, function () {
|
23556 | var offset = this.utcOffset();
|
23557 | var sign = '+';
|
23558 |
|
23559 | if (offset < 0) {
|
23560 | offset = -offset;
|
23561 | sign = '-';
|
23562 | }
|
23563 |
|
23564 | return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~offset % 60, 2);
|
23565 | });
|
23566 | }
|
23567 |
|
23568 | offset('Z', ':');
|
23569 | offset('ZZ', '');
|
23570 |
|
23571 | addRegexToken('Z', matchShortOffset);
|
23572 | addRegexToken('ZZ', matchShortOffset);
|
23573 | addParseToken(['Z', 'ZZ'], function (input, array, config) {
|
23574 | config._useUTC = true;
|
23575 | config._tzm = offsetFromString(matchShortOffset, input);
|
23576 | });
|
23577 |
|
23578 |
|
23579 |
|
23580 |
|
23581 | var chunkOffset = /([\+\-]|\d\d)/gi;
|
23582 |
|
23583 | function offsetFromString(matcher, string) {
|
23584 | var matches = (string || '').match(matcher);
|
23585 |
|
23586 | if (matches === null) {
|
23587 | return null;
|
23588 | }
|
23589 |
|
23590 | var chunk = matches[matches.length - 1] || [];
|
23591 | var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
|
23592 | var minutes = +(parts[1] * 60) + toInt(parts[2]);
|
23593 | return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
|
23594 | }
|
23595 |
|
23596 |
|
23597 | function cloneWithOffset(input, model) {
|
23598 | var res, diff;
|
23599 |
|
23600 | if (model._isUTC) {
|
23601 | res = model.clone();
|
23602 | diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
|
23603 |
|
23604 | res._d.setTime(res._d.valueOf() + diff);
|
23605 |
|
23606 | hooks.updateOffset(res, false);
|
23607 | return res;
|
23608 | } else {
|
23609 | return createLocal(input).local();
|
23610 | }
|
23611 | }
|
23612 |
|
23613 | function getDateOffset(m) {
|
23614 |
|
23615 |
|
23616 | return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
|
23617 | }
|
23618 |
|
23619 |
|
23620 |
|
23621 |
|
23622 | hooks.updateOffset = function () {};
|
23623 |
|
23624 |
|
23625 |
|
23626 |
|
23627 |
|
23628 |
|
23629 |
|
23630 |
|
23631 |
|
23632 |
|
23633 |
|
23634 |
|
23635 | function getSetOffset(input, keepLocalTime, keepMinutes) {
|
23636 | var offset = this._offset || 0,
|
23637 | localAdjust;
|
23638 |
|
23639 | if (!this.isValid()) {
|
23640 | return input != null ? this : NaN;
|
23641 | }
|
23642 |
|
23643 | if (input != null) {
|
23644 | if (typeof input === 'string') {
|
23645 | input = offsetFromString(matchShortOffset, input);
|
23646 |
|
23647 | if (input === null) {
|
23648 | return this;
|
23649 | }
|
23650 | } else if (Math.abs(input) < 16 && !keepMinutes) {
|
23651 | input = input * 60;
|
23652 | }
|
23653 |
|
23654 | if (!this._isUTC && keepLocalTime) {
|
23655 | localAdjust = getDateOffset(this);
|
23656 | }
|
23657 |
|
23658 | this._offset = input;
|
23659 | this._isUTC = true;
|
23660 |
|
23661 | if (localAdjust != null) {
|
23662 | this.add(localAdjust, 'm');
|
23663 | }
|
23664 |
|
23665 | if (offset !== input) {
|
23666 | if (!keepLocalTime || this._changeInProgress) {
|
23667 | addSubtract(this, createDuration(input - offset, 'm'), 1, false);
|
23668 | } else if (!this._changeInProgress) {
|
23669 | this._changeInProgress = true;
|
23670 | hooks.updateOffset(this, true);
|
23671 | this._changeInProgress = null;
|
23672 | }
|
23673 | }
|
23674 |
|
23675 | return this;
|
23676 | } else {
|
23677 | return this._isUTC ? offset : getDateOffset(this);
|
23678 | }
|
23679 | }
|
23680 |
|
23681 | function getSetZone(input, keepLocalTime) {
|
23682 | if (input != null) {
|
23683 | if (typeof input !== 'string') {
|
23684 | input = -input;
|
23685 | }
|
23686 |
|
23687 | this.utcOffset(input, keepLocalTime);
|
23688 | return this;
|
23689 | } else {
|
23690 | return -this.utcOffset();
|
23691 | }
|
23692 | }
|
23693 |
|
23694 | function setOffsetToUTC(keepLocalTime) {
|
23695 | return this.utcOffset(0, keepLocalTime);
|
23696 | }
|
23697 |
|
23698 | function setOffsetToLocal(keepLocalTime) {
|
23699 | if (this._isUTC) {
|
23700 | this.utcOffset(0, keepLocalTime);
|
23701 | this._isUTC = false;
|
23702 |
|
23703 | if (keepLocalTime) {
|
23704 | this.subtract(getDateOffset(this), 'm');
|
23705 | }
|
23706 | }
|
23707 |
|
23708 | return this;
|
23709 | }
|
23710 |
|
23711 | function setOffsetToParsedOffset() {
|
23712 | if (this._tzm != null) {
|
23713 | this.utcOffset(this._tzm, false, true);
|
23714 | } else if (typeof this._i === 'string') {
|
23715 | var tZone = offsetFromString(matchOffset, this._i);
|
23716 |
|
23717 | if (tZone != null) {
|
23718 | this.utcOffset(tZone);
|
23719 | } else {
|
23720 | this.utcOffset(0, true);
|
23721 | }
|
23722 | }
|
23723 |
|
23724 | return this;
|
23725 | }
|
23726 |
|
23727 | function hasAlignedHourOffset(input) {
|
23728 | if (!this.isValid()) {
|
23729 | return false;
|
23730 | }
|
23731 |
|
23732 | input = input ? createLocal(input).utcOffset() : 0;
|
23733 | return (this.utcOffset() - input) % 60 === 0;
|
23734 | }
|
23735 |
|
23736 | function isDaylightSavingTime() {
|
23737 | return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset();
|
23738 | }
|
23739 |
|
23740 | function isDaylightSavingTimeShifted() {
|
23741 | if (!isUndefined(this._isDSTShifted)) {
|
23742 | return this._isDSTShifted;
|
23743 | }
|
23744 |
|
23745 | var c = {};
|
23746 | copyConfig(c, this);
|
23747 | c = prepareConfig(c);
|
23748 |
|
23749 | if (c._a) {
|
23750 | var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
|
23751 | this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0;
|
23752 | } else {
|
23753 | this._isDSTShifted = false;
|
23754 | }
|
23755 |
|
23756 | return this._isDSTShifted;
|
23757 | }
|
23758 |
|
23759 | function isLocal() {
|
23760 | return this.isValid() ? !this._isUTC : false;
|
23761 | }
|
23762 |
|
23763 | function isUtcOffset() {
|
23764 | return this.isValid() ? this._isUTC : false;
|
23765 | }
|
23766 |
|
23767 | function isUtc() {
|
23768 | return this.isValid() ? this._isUTC && this._offset === 0 : false;
|
23769 | }
|
23770 |
|
23771 |
|
23772 | var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
|
23773 |
|
23774 |
|
23775 |
|
23776 | var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
|
23777 |
|
23778 | function createDuration(input, key) {
|
23779 | var duration = input,
|
23780 |
|
23781 | match = null,
|
23782 | sign,
|
23783 | ret,
|
23784 | diffRes;
|
23785 |
|
23786 | if (isDuration(input)) {
|
23787 | duration = {
|
23788 | ms: input._milliseconds,
|
23789 | d: input._days,
|
23790 | M: input._months
|
23791 | };
|
23792 | } else if (isNumber(input)) {
|
23793 | duration = {};
|
23794 |
|
23795 | if (key) {
|
23796 | duration[key] = input;
|
23797 | } else {
|
23798 | duration.milliseconds = input;
|
23799 | }
|
23800 | } else if (!!(match = aspNetRegex.exec(input))) {
|
23801 | sign = match[1] === '-' ? -1 : 1;
|
23802 | duration = {
|
23803 | y: 0,
|
23804 | d: toInt(match[DATE]) * sign,
|
23805 | h: toInt(match[HOUR]) * sign,
|
23806 | m: toInt(match[MINUTE]) * sign,
|
23807 | s: toInt(match[SECOND]) * sign,
|
23808 | ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign
|
23809 |
|
23810 | };
|
23811 | } else if (!!(match = isoRegex.exec(input))) {
|
23812 | sign = match[1] === '-' ? -1 : 1;
|
23813 | duration = {
|
23814 | y: parseIso(match[2], sign),
|
23815 | M: parseIso(match[3], sign),
|
23816 | w: parseIso(match[4], sign),
|
23817 | d: parseIso(match[5], sign),
|
23818 | h: parseIso(match[6], sign),
|
23819 | m: parseIso(match[7], sign),
|
23820 | s: parseIso(match[8], sign)
|
23821 | };
|
23822 | } else if (duration == null) {
|
23823 |
|
23824 | duration = {};
|
23825 | } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
|
23826 | diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
|
23827 | duration = {};
|
23828 | duration.ms = diffRes.milliseconds;
|
23829 | duration.M = diffRes.months;
|
23830 | }
|
23831 |
|
23832 | ret = new Duration(duration);
|
23833 |
|
23834 | if (isDuration(input) && hasOwnProp(input, '_locale')) {
|
23835 | ret._locale = input._locale;
|
23836 | }
|
23837 |
|
23838 | return ret;
|
23839 | }
|
23840 |
|
23841 | createDuration.fn = Duration.prototype;
|
23842 | createDuration.invalid = createInvalid$1;
|
23843 |
|
23844 | function parseIso(inp, sign) {
|
23845 |
|
23846 |
|
23847 |
|
23848 | var res = inp && parseFloat(inp.replace(',', '.'));
|
23849 |
|
23850 | return (isNaN(res) ? 0 : res) * sign;
|
23851 | }
|
23852 |
|
23853 | function positiveMomentsDifference(base, other) {
|
23854 | var res = {};
|
23855 | res.months = other.month() - base.month() + (other.year() - base.year()) * 12;
|
23856 |
|
23857 | if (base.clone().add(res.months, 'M').isAfter(other)) {
|
23858 | --res.months;
|
23859 | }
|
23860 |
|
23861 | res.milliseconds = +other - +base.clone().add(res.months, 'M');
|
23862 | return res;
|
23863 | }
|
23864 |
|
23865 | function momentsDifference(base, other) {
|
23866 | var res;
|
23867 |
|
23868 | if (!(base.isValid() && other.isValid())) {
|
23869 | return {
|
23870 | milliseconds: 0,
|
23871 | months: 0
|
23872 | };
|
23873 | }
|
23874 |
|
23875 | other = cloneWithOffset(other, base);
|
23876 |
|
23877 | if (base.isBefore(other)) {
|
23878 | res = positiveMomentsDifference(base, other);
|
23879 | } else {
|
23880 | res = positiveMomentsDifference(other, base);
|
23881 | res.milliseconds = -res.milliseconds;
|
23882 | res.months = -res.months;
|
23883 | }
|
23884 |
|
23885 | return res;
|
23886 | }
|
23887 |
|
23888 |
|
23889 | function createAdder(direction, name) {
|
23890 | return function (val, period) {
|
23891 | var dur, tmp;
|
23892 |
|
23893 | if (period !== null && !isNaN(+period)) {
|
23894 | deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
|
23895 | tmp = val;
|
23896 | val = period;
|
23897 | period = tmp;
|
23898 | }
|
23899 |
|
23900 | val = typeof val === 'string' ? +val : val;
|
23901 | dur = createDuration(val, period);
|
23902 | addSubtract(this, dur, direction);
|
23903 | return this;
|
23904 | };
|
23905 | }
|
23906 |
|
23907 | function addSubtract(mom, duration, isAdding, updateOffset) {
|
23908 | var milliseconds = duration._milliseconds,
|
23909 | days = absRound(duration._days),
|
23910 | months = absRound(duration._months);
|
23911 |
|
23912 | if (!mom.isValid()) {
|
23913 |
|
23914 | return;
|
23915 | }
|
23916 |
|
23917 | updateOffset = updateOffset == null ? true : updateOffset;
|
23918 |
|
23919 | if (months) {
|
23920 | setMonth(mom, get(mom, 'Month') + months * isAdding);
|
23921 | }
|
23922 |
|
23923 | if (days) {
|
23924 | set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
|
23925 | }
|
23926 |
|
23927 | if (milliseconds) {
|
23928 | mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
23929 | }
|
23930 |
|
23931 | if (updateOffset) {
|
23932 | hooks.updateOffset(mom, days || months);
|
23933 | }
|
23934 | }
|
23935 |
|
23936 | var add = createAdder(1, 'add');
|
23937 | var subtract = createAdder(-1, 'subtract');
|
23938 |
|
23939 | function getCalendarFormat(myMoment, now) {
|
23940 | var diff = myMoment.diff(now, 'days', true);
|
23941 | return diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse';
|
23942 | }
|
23943 |
|
23944 | function calendar$1(time, formats) {
|
23945 |
|
23946 |
|
23947 | var now = time || createLocal(),
|
23948 | sod = cloneWithOffset(now, this).startOf('day'),
|
23949 | format = hooks.calendarFormat(this, sod) || 'sameElse';
|
23950 | var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
|
23951 | return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
|
23952 | }
|
23953 |
|
23954 | function clone() {
|
23955 | return new Moment(this);
|
23956 | }
|
23957 |
|
23958 | function isAfter(input, units) {
|
23959 | var localInput = isMoment(input) ? input : createLocal(input);
|
23960 |
|
23961 | if (!(this.isValid() && localInput.isValid())) {
|
23962 | return false;
|
23963 | }
|
23964 |
|
23965 | units = normalizeUnits(units) || 'millisecond';
|
23966 |
|
23967 | if (units === 'millisecond') {
|
23968 | return this.valueOf() > localInput.valueOf();
|
23969 | } else {
|
23970 | return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
23971 | }
|
23972 | }
|
23973 |
|
23974 | function isBefore(input, units) {
|
23975 | var localInput = isMoment(input) ? input : createLocal(input);
|
23976 |
|
23977 | if (!(this.isValid() && localInput.isValid())) {
|
23978 | return false;
|
23979 | }
|
23980 |
|
23981 | units = normalizeUnits(units) || 'millisecond';
|
23982 |
|
23983 | if (units === 'millisecond') {
|
23984 | return this.valueOf() < localInput.valueOf();
|
23985 | } else {
|
23986 | return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
23987 | }
|
23988 | }
|
23989 |
|
23990 | function isBetween(from, to, units, inclusivity) {
|
23991 | var localFrom = isMoment(from) ? from : createLocal(from),
|
23992 | localTo = isMoment(to) ? to : createLocal(to);
|
23993 |
|
23994 | if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
23995 | return false;
|
23996 | }
|
23997 |
|
23998 | inclusivity = inclusivity || '()';
|
23999 | return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
24000 | }
|
24001 |
|
24002 | function isSame(input, units) {
|
24003 | var localInput = isMoment(input) ? input : createLocal(input),
|
24004 | inputMs;
|
24005 |
|
24006 | if (!(this.isValid() && localInput.isValid())) {
|
24007 | return false;
|
24008 | }
|
24009 |
|
24010 | units = normalizeUnits(units) || 'millisecond';
|
24011 |
|
24012 | if (units === 'millisecond') {
|
24013 | return this.valueOf() === localInput.valueOf();
|
24014 | } else {
|
24015 | inputMs = localInput.valueOf();
|
24016 | return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
24017 | }
|
24018 | }
|
24019 |
|
24020 | function isSameOrAfter(input, units) {
|
24021 | return this.isSame(input, units) || this.isAfter(input, units);
|
24022 | }
|
24023 |
|
24024 | function isSameOrBefore(input, units) {
|
24025 | return this.isSame(input, units) || this.isBefore(input, units);
|
24026 | }
|
24027 |
|
24028 | function diff(input, units, asFloat) {
|
24029 | var that, zoneDelta, output;
|
24030 |
|
24031 | if (!this.isValid()) {
|
24032 | return NaN;
|
24033 | }
|
24034 |
|
24035 | that = cloneWithOffset(input, this);
|
24036 |
|
24037 | if (!that.isValid()) {
|
24038 | return NaN;
|
24039 | }
|
24040 |
|
24041 | zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
|
24042 | units = normalizeUnits(units);
|
24043 |
|
24044 | switch (units) {
|
24045 | case 'year':
|
24046 | output = monthDiff(this, that) / 12;
|
24047 | break;
|
24048 |
|
24049 | case 'month':
|
24050 | output = monthDiff(this, that);
|
24051 | break;
|
24052 |
|
24053 | case 'quarter':
|
24054 | output = monthDiff(this, that) / 3;
|
24055 | break;
|
24056 |
|
24057 | case 'second':
|
24058 | output = (this - that) / 1e3;
|
24059 | break;
|
24060 |
|
24061 |
|
24062 | case 'minute':
|
24063 | output = (this - that) / 6e4;
|
24064 | break;
|
24065 |
|
24066 |
|
24067 | case 'hour':
|
24068 | output = (this - that) / 36e5;
|
24069 | break;
|
24070 |
|
24071 |
|
24072 | case 'day':
|
24073 | output = (this - that - zoneDelta) / 864e5;
|
24074 | break;
|
24075 |
|
24076 |
|
24077 | case 'week':
|
24078 | output = (this - that - zoneDelta) / 6048e5;
|
24079 | break;
|
24080 |
|
24081 |
|
24082 | default:
|
24083 | output = this - that;
|
24084 | }
|
24085 |
|
24086 | return asFloat ? output : absFloor(output);
|
24087 | }
|
24088 |
|
24089 | function monthDiff(a, b) {
|
24090 |
|
24091 | var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
|
24092 |
|
24093 | anchor = a.clone().add(wholeMonthDiff, 'months'),
|
24094 | anchor2,
|
24095 | adjust;
|
24096 |
|
24097 | if (b - anchor < 0) {
|
24098 | anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
|
24099 |
|
24100 | adjust = (b - anchor) / (anchor - anchor2);
|
24101 | } else {
|
24102 | anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
|
24103 |
|
24104 | adjust = (b - anchor) / (anchor2 - anchor);
|
24105 | }
|
24106 |
|
24107 |
|
24108 | return -(wholeMonthDiff + adjust) || 0;
|
24109 | }
|
24110 |
|
24111 | hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
24112 | hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
24113 |
|
24114 | function toString() {
|
24115 | return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
24116 | }
|
24117 |
|
24118 | function toISOString(keepOffset) {
|
24119 | if (!this.isValid()) {
|
24120 | return null;
|
24121 | }
|
24122 |
|
24123 | var utc = keepOffset !== true;
|
24124 | var m = utc ? this.clone().utc() : this;
|
24125 |
|
24126 | if (m.year() < 0 || m.year() > 9999) {
|
24127 | return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
24128 | }
|
24129 |
|
24130 | if (isFunction(Date.prototype.toISOString)) {
|
24131 |
|
24132 | if (utc) {
|
24133 | return this.toDate().toISOString();
|
24134 | } else {
|
24135 | return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
|
24136 | }
|
24137 | }
|
24138 |
|
24139 | return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
|
24140 | }
|
24141 | |
24142 |
|
24143 |
|
24144 |
|
24145 |
|
24146 |
|
24147 |
|
24148 |
|
24149 | function inspect() {
|
24150 | if (!this.isValid()) {
|
24151 | return 'moment.invalid(/* ' + this._i + ' */)';
|
24152 | }
|
24153 |
|
24154 | var func = 'moment';
|
24155 | var zone = '';
|
24156 |
|
24157 | if (!this.isLocal()) {
|
24158 | func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
|
24159 | zone = 'Z';
|
24160 | }
|
24161 |
|
24162 | var prefix = '[' + func + '("]';
|
24163 | var year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
|
24164 | var datetime = '-MM-DD[T]HH:mm:ss.SSS';
|
24165 | var suffix = zone + '[")]';
|
24166 | return this.format(prefix + year + datetime + suffix);
|
24167 | }
|
24168 |
|
24169 | function format(inputString) {
|
24170 | if (!inputString) {
|
24171 | inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
|
24172 | }
|
24173 |
|
24174 | var output = formatMoment(this, inputString);
|
24175 | return this.localeData().postformat(output);
|
24176 | }
|
24177 |
|
24178 | function from(time, withoutSuffix) {
|
24179 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
24180 | return createDuration({
|
24181 | to: this,
|
24182 | from: time
|
24183 | }).locale(this.locale()).humanize(!withoutSuffix);
|
24184 | } else {
|
24185 | return this.localeData().invalidDate();
|
24186 | }
|
24187 | }
|
24188 |
|
24189 | function fromNow(withoutSuffix) {
|
24190 | return this.from(createLocal(), withoutSuffix);
|
24191 | }
|
24192 |
|
24193 | function to(time, withoutSuffix) {
|
24194 | if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
|
24195 | return createDuration({
|
24196 | from: this,
|
24197 | to: time
|
24198 | }).locale(this.locale()).humanize(!withoutSuffix);
|
24199 | } else {
|
24200 | return this.localeData().invalidDate();
|
24201 | }
|
24202 | }
|
24203 |
|
24204 | function toNow(withoutSuffix) {
|
24205 | return this.to(createLocal(), withoutSuffix);
|
24206 | }
|
24207 |
|
24208 |
|
24209 |
|
24210 |
|
24211 | function locale(key) {
|
24212 | var newLocaleData;
|
24213 |
|
24214 | if (key === undefined) {
|
24215 | return this._locale._abbr;
|
24216 | } else {
|
24217 | newLocaleData = getLocale(key);
|
24218 |
|
24219 | if (newLocaleData != null) {
|
24220 | this._locale = newLocaleData;
|
24221 | }
|
24222 |
|
24223 | return this;
|
24224 | }
|
24225 | }
|
24226 |
|
24227 | var lang = deprecate('moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', function (key) {
|
24228 | if (key === undefined) {
|
24229 | return this.localeData();
|
24230 | } else {
|
24231 | return this.locale(key);
|
24232 | }
|
24233 | });
|
24234 |
|
24235 | function localeData() {
|
24236 | return this._locale;
|
24237 | }
|
24238 |
|
24239 | var MS_PER_SECOND = 1000;
|
24240 | var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
24241 | var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
24242 | var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
24243 |
|
24244 | function mod$1(dividend, divisor) {
|
24245 | return (dividend % divisor + divisor) % divisor;
|
24246 | }
|
24247 |
|
24248 | function localStartOfDate(y, m, d) {
|
24249 |
|
24250 | if (y < 100 && y >= 0) {
|
24251 |
|
24252 | return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
24253 | } else {
|
24254 | return new Date(y, m, d).valueOf();
|
24255 | }
|
24256 | }
|
24257 |
|
24258 | function utcStartOfDate(y, m, d) {
|
24259 |
|
24260 | if (y < 100 && y >= 0) {
|
24261 |
|
24262 | return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
24263 | } else {
|
24264 | return Date.UTC(y, m, d);
|
24265 | }
|
24266 | }
|
24267 |
|
24268 | function startOf(units) {
|
24269 | var time;
|
24270 | units = normalizeUnits(units);
|
24271 |
|
24272 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
24273 | return this;
|
24274 | }
|
24275 |
|
24276 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
24277 |
|
24278 | switch (units) {
|
24279 | case 'year':
|
24280 | time = startOfDate(this.year(), 0, 1);
|
24281 | break;
|
24282 |
|
24283 | case 'quarter':
|
24284 | time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
24285 | break;
|
24286 |
|
24287 | case 'month':
|
24288 | time = startOfDate(this.year(), this.month(), 1);
|
24289 | break;
|
24290 |
|
24291 | case 'week':
|
24292 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
24293 | break;
|
24294 |
|
24295 | case 'isoWeek':
|
24296 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
24297 | break;
|
24298 |
|
24299 | case 'day':
|
24300 | case 'date':
|
24301 | time = startOfDate(this.year(), this.month(), this.date());
|
24302 | break;
|
24303 |
|
24304 | case 'hour':
|
24305 | time = this._d.valueOf();
|
24306 | time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
24307 | break;
|
24308 |
|
24309 | case 'minute':
|
24310 | time = this._d.valueOf();
|
24311 | time -= mod$1(time, MS_PER_MINUTE);
|
24312 | break;
|
24313 |
|
24314 | case 'second':
|
24315 | time = this._d.valueOf();
|
24316 | time -= mod$1(time, MS_PER_SECOND);
|
24317 | break;
|
24318 | }
|
24319 |
|
24320 | this._d.setTime(time);
|
24321 |
|
24322 | hooks.updateOffset(this, true);
|
24323 | return this;
|
24324 | }
|
24325 |
|
24326 | function endOf(units) {
|
24327 | var time;
|
24328 | units = normalizeUnits(units);
|
24329 |
|
24330 | if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
24331 | return this;
|
24332 | }
|
24333 |
|
24334 | var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
24335 |
|
24336 | switch (units) {
|
24337 | case 'year':
|
24338 | time = startOfDate(this.year() + 1, 0, 1) - 1;
|
24339 | break;
|
24340 |
|
24341 | case 'quarter':
|
24342 | time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
24343 | break;
|
24344 |
|
24345 | case 'month':
|
24346 | time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
24347 | break;
|
24348 |
|
24349 | case 'week':
|
24350 | time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
24351 | break;
|
24352 |
|
24353 | case 'isoWeek':
|
24354 | time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
24355 | break;
|
24356 |
|
24357 | case 'day':
|
24358 | case 'date':
|
24359 | time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
24360 | break;
|
24361 |
|
24362 | case 'hour':
|
24363 | time = this._d.valueOf();
|
24364 | time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
24365 | break;
|
24366 |
|
24367 | case 'minute':
|
24368 | time = this._d.valueOf();
|
24369 | time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
24370 | break;
|
24371 |
|
24372 | case 'second':
|
24373 | time = this._d.valueOf();
|
24374 | time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
24375 | break;
|
24376 | }
|
24377 |
|
24378 | this._d.setTime(time);
|
24379 |
|
24380 | hooks.updateOffset(this, true);
|
24381 | return this;
|
24382 | }
|
24383 |
|
24384 | function valueOf() {
|
24385 | return this._d.valueOf() - (this._offset || 0) * 60000;
|
24386 | }
|
24387 |
|
24388 | function unix() {
|
24389 | return Math.floor(this.valueOf() / 1000);
|
24390 | }
|
24391 |
|
24392 | function toDate() {
|
24393 | return new Date(this.valueOf());
|
24394 | }
|
24395 |
|
24396 | function toArray() {
|
24397 | var m = this;
|
24398 | return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
|
24399 | }
|
24400 |
|
24401 | function toObject() {
|
24402 | var m = this;
|
24403 | return {
|
24404 | years: m.year(),
|
24405 | months: m.month(),
|
24406 | date: m.date(),
|
24407 | hours: m.hours(),
|
24408 | minutes: m.minutes(),
|
24409 | seconds: m.seconds(),
|
24410 | milliseconds: m.milliseconds()
|
24411 | };
|
24412 | }
|
24413 |
|
24414 | function toJSON() {
|
24415 |
|
24416 | return this.isValid() ? this.toISOString() : null;
|
24417 | }
|
24418 |
|
24419 | function isValid$2() {
|
24420 | return isValid(this);
|
24421 | }
|
24422 |
|
24423 | function parsingFlags() {
|
24424 | return extend({}, getParsingFlags(this));
|
24425 | }
|
24426 |
|
24427 | function invalidAt() {
|
24428 | return getParsingFlags(this).overflow;
|
24429 | }
|
24430 |
|
24431 | function creationData() {
|
24432 | return {
|
24433 | input: this._i,
|
24434 | format: this._f,
|
24435 | locale: this._locale,
|
24436 | isUTC: this._isUTC,
|
24437 | strict: this._strict
|
24438 | };
|
24439 | }
|
24440 |
|
24441 |
|
24442 | addFormatToken(0, ['gg', 2], 0, function () {
|
24443 | return this.weekYear() % 100;
|
24444 | });
|
24445 | addFormatToken(0, ['GG', 2], 0, function () {
|
24446 | return this.isoWeekYear() % 100;
|
24447 | });
|
24448 |
|
24449 | function addWeekYearFormatToken(token, getter) {
|
24450 | addFormatToken(0, [token, token.length], 0, getter);
|
24451 | }
|
24452 |
|
24453 | addWeekYearFormatToken('gggg', 'weekYear');
|
24454 | addWeekYearFormatToken('ggggg', 'weekYear');
|
24455 | addWeekYearFormatToken('GGGG', 'isoWeekYear');
|
24456 | addWeekYearFormatToken('GGGGG', 'isoWeekYear');
|
24457 |
|
24458 | addUnitAlias('weekYear', 'gg');
|
24459 | addUnitAlias('isoWeekYear', 'GG');
|
24460 |
|
24461 | addUnitPriority('weekYear', 1);
|
24462 | addUnitPriority('isoWeekYear', 1);
|
24463 |
|
24464 | addRegexToken('G', matchSigned);
|
24465 | addRegexToken('g', matchSigned);
|
24466 | addRegexToken('GG', match1to2, match2);
|
24467 | addRegexToken('gg', match1to2, match2);
|
24468 | addRegexToken('GGGG', match1to4, match4);
|
24469 | addRegexToken('gggg', match1to4, match4);
|
24470 | addRegexToken('GGGGG', match1to6, match6);
|
24471 | addRegexToken('ggggg', match1to6, match6);
|
24472 | addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
|
24473 | week[token.substr(0, 2)] = toInt(input);
|
24474 | });
|
24475 | addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
|
24476 | week[token] = hooks.parseTwoDigitYear(input);
|
24477 | });
|
24478 |
|
24479 | function getSetWeekYear(input) {
|
24480 | return getSetWeekYearHelper.call(this, input, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy);
|
24481 | }
|
24482 |
|
24483 | function getSetISOWeekYear(input) {
|
24484 | return getSetWeekYearHelper.call(this, input, this.isoWeek(), this.isoWeekday(), 1, 4);
|
24485 | }
|
24486 |
|
24487 | function getISOWeeksInYear() {
|
24488 | return weeksInYear(this.year(), 1, 4);
|
24489 | }
|
24490 |
|
24491 | function getWeeksInYear() {
|
24492 | var weekInfo = this.localeData()._week;
|
24493 |
|
24494 | return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
24495 | }
|
24496 |
|
24497 | function getSetWeekYearHelper(input, week, weekday, dow, doy) {
|
24498 | var weeksTarget;
|
24499 |
|
24500 | if (input == null) {
|
24501 | return weekOfYear(this, dow, doy).year;
|
24502 | } else {
|
24503 | weeksTarget = weeksInYear(input, dow, doy);
|
24504 |
|
24505 | if (week > weeksTarget) {
|
24506 | week = weeksTarget;
|
24507 | }
|
24508 |
|
24509 | return setWeekAll.call(this, input, week, weekday, dow, doy);
|
24510 | }
|
24511 | }
|
24512 |
|
24513 | function setWeekAll(weekYear, week, weekday, dow, doy) {
|
24514 | var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
|
24515 | date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
|
24516 | this.year(date.getUTCFullYear());
|
24517 | this.month(date.getUTCMonth());
|
24518 | this.date(date.getUTCDate());
|
24519 | return this;
|
24520 | }
|
24521 |
|
24522 |
|
24523 | addFormatToken('Q', 0, 'Qo', 'quarter');
|
24524 |
|
24525 | addUnitAlias('quarter', 'Q');
|
24526 |
|
24527 | addUnitPriority('quarter', 7);
|
24528 |
|
24529 | addRegexToken('Q', match1);
|
24530 | addParseToken('Q', function (input, array) {
|
24531 | array[MONTH] = (toInt(input) - 1) * 3;
|
24532 | });
|
24533 |
|
24534 | function getSetQuarter(input) {
|
24535 | return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
24536 | }
|
24537 |
|
24538 |
|
24539 | addFormatToken('D', ['DD', 2], 'Do', 'date');
|
24540 |
|
24541 | addUnitAlias('date', 'D');
|
24542 |
|
24543 | addUnitPriority('date', 9);
|
24544 |
|
24545 | addRegexToken('D', match1to2);
|
24546 | addRegexToken('DD', match1to2, match2);
|
24547 | addRegexToken('Do', function (isStrict, locale) {
|
24548 |
|
24549 | return isStrict ? locale._dayOfMonthOrdinalParse || locale._ordinalParse : locale._dayOfMonthOrdinalParseLenient;
|
24550 | });
|
24551 | addParseToken(['D', 'DD'], DATE);
|
24552 | addParseToken('Do', function (input, array) {
|
24553 | array[DATE] = toInt(input.match(match1to2)[0]);
|
24554 | });
|
24555 |
|
24556 | var getSetDayOfMonth = makeGetSet('Date', true);
|
24557 |
|
24558 | addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
24559 |
|
24560 | addUnitAlias('dayOfYear', 'DDD');
|
24561 |
|
24562 | addUnitPriority('dayOfYear', 4);
|
24563 |
|
24564 | addRegexToken('DDD', match1to3);
|
24565 | addRegexToken('DDDD', match3);
|
24566 | addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
24567 | config._dayOfYear = toInt(input);
|
24568 | });
|
24569 |
|
24570 |
|
24571 | function getSetDayOfYear(input) {
|
24572 | var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
24573 | return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
|
24574 | }
|
24575 |
|
24576 |
|
24577 | addFormatToken('m', ['mm', 2], 0, 'minute');
|
24578 |
|
24579 | addUnitAlias('minute', 'm');
|
24580 |
|
24581 | addUnitPriority('minute', 14);
|
24582 |
|
24583 | addRegexToken('m', match1to2);
|
24584 | addRegexToken('mm', match1to2, match2);
|
24585 | addParseToken(['m', 'mm'], MINUTE);
|
24586 |
|
24587 | var getSetMinute = makeGetSet('Minutes', false);
|
24588 |
|
24589 | addFormatToken('s', ['ss', 2], 0, 'second');
|
24590 |
|
24591 | addUnitAlias('second', 's');
|
24592 |
|
24593 | addUnitPriority('second', 15);
|
24594 |
|
24595 | addRegexToken('s', match1to2);
|
24596 | addRegexToken('ss', match1to2, match2);
|
24597 | addParseToken(['s', 'ss'], SECOND);
|
24598 |
|
24599 | var getSetSecond = makeGetSet('Seconds', false);
|
24600 |
|
24601 | addFormatToken('S', 0, 0, function () {
|
24602 | return ~~(this.millisecond() / 100);
|
24603 | });
|
24604 | addFormatToken(0, ['SS', 2], 0, function () {
|
24605 | return ~~(this.millisecond() / 10);
|
24606 | });
|
24607 | addFormatToken(0, ['SSS', 3], 0, 'millisecond');
|
24608 | addFormatToken(0, ['SSSS', 4], 0, function () {
|
24609 | return this.millisecond() * 10;
|
24610 | });
|
24611 | addFormatToken(0, ['SSSSS', 5], 0, function () {
|
24612 | return this.millisecond() * 100;
|
24613 | });
|
24614 | addFormatToken(0, ['SSSSSS', 6], 0, function () {
|
24615 | return this.millisecond() * 1000;
|
24616 | });
|
24617 | addFormatToken(0, ['SSSSSSS', 7], 0, function () {
|
24618 | return this.millisecond() * 10000;
|
24619 | });
|
24620 | addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
|
24621 | return this.millisecond() * 100000;
|
24622 | });
|
24623 | addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
|
24624 | return this.millisecond() * 1000000;
|
24625 | });
|
24626 |
|
24627 | addUnitAlias('millisecond', 'ms');
|
24628 |
|
24629 | addUnitPriority('millisecond', 16);
|
24630 |
|
24631 | addRegexToken('S', match1to3, match1);
|
24632 | addRegexToken('SS', match1to3, match2);
|
24633 | addRegexToken('SSS', match1to3, match3);
|
24634 | var token;
|
24635 |
|
24636 | for (token = 'SSSS'; token.length <= 9; token += 'S') {
|
24637 | addRegexToken(token, matchUnsigned);
|
24638 | }
|
24639 |
|
24640 | function parseMs(input, array) {
|
24641 | array[MILLISECOND] = toInt(('0.' + input) * 1000);
|
24642 | }
|
24643 |
|
24644 | for (token = 'S'; token.length <= 9; token += 'S') {
|
24645 | addParseToken(token, parseMs);
|
24646 | }
|
24647 |
|
24648 |
|
24649 | var getSetMillisecond = makeGetSet('Milliseconds', false);
|
24650 |
|
24651 | addFormatToken('z', 0, 0, 'zoneAbbr');
|
24652 | addFormatToken('zz', 0, 0, 'zoneName');
|
24653 |
|
24654 | function getZoneAbbr() {
|
24655 | return this._isUTC ? 'UTC' : '';
|
24656 | }
|
24657 |
|
24658 | function getZoneName() {
|
24659 | return this._isUTC ? 'Coordinated Universal Time' : '';
|
24660 | }
|
24661 |
|
24662 | var proto = Moment.prototype;
|
24663 | proto.add = add;
|
24664 | proto.calendar = calendar$1;
|
24665 | proto.clone = clone;
|
24666 | proto.diff = diff;
|
24667 | proto.endOf = endOf;
|
24668 | proto.format = format;
|
24669 | proto.from = from;
|
24670 | proto.fromNow = fromNow;
|
24671 | proto.to = to;
|
24672 | proto.toNow = toNow;
|
24673 | proto.get = stringGet;
|
24674 | proto.invalidAt = invalidAt;
|
24675 | proto.isAfter = isAfter;
|
24676 | proto.isBefore = isBefore;
|
24677 | proto.isBetween = isBetween;
|
24678 | proto.isSame = isSame;
|
24679 | proto.isSameOrAfter = isSameOrAfter;
|
24680 | proto.isSameOrBefore = isSameOrBefore;
|
24681 | proto.isValid = isValid$2;
|
24682 | proto.lang = lang;
|
24683 | proto.locale = locale;
|
24684 | proto.localeData = localeData;
|
24685 | proto.max = prototypeMax;
|
24686 | proto.min = prototypeMin;
|
24687 | proto.parsingFlags = parsingFlags;
|
24688 | proto.set = stringSet;
|
24689 | proto.startOf = startOf;
|
24690 | proto.subtract = subtract;
|
24691 | proto.toArray = toArray;
|
24692 | proto.toObject = toObject;
|
24693 | proto.toDate = toDate;
|
24694 | proto.toISOString = toISOString;
|
24695 | proto.inspect = inspect;
|
24696 | proto.toJSON = toJSON;
|
24697 | proto.toString = toString;
|
24698 | proto.unix = unix;
|
24699 | proto.valueOf = valueOf;
|
24700 | proto.creationData = creationData;
|
24701 | proto.year = getSetYear;
|
24702 | proto.isLeapYear = getIsLeapYear;
|
24703 | proto.weekYear = getSetWeekYear;
|
24704 | proto.isoWeekYear = getSetISOWeekYear;
|
24705 | proto.quarter = proto.quarters = getSetQuarter;
|
24706 | proto.month = getSetMonth;
|
24707 | proto.daysInMonth = getDaysInMonth;
|
24708 | proto.week = proto.weeks = getSetWeek;
|
24709 | proto.isoWeek = proto.isoWeeks = getSetISOWeek;
|
24710 | proto.weeksInYear = getWeeksInYear;
|
24711 | proto.isoWeeksInYear = getISOWeeksInYear;
|
24712 | proto.date = getSetDayOfMonth;
|
24713 | proto.day = proto.days = getSetDayOfWeek;
|
24714 | proto.weekday = getSetLocaleDayOfWeek;
|
24715 | proto.isoWeekday = getSetISODayOfWeek;
|
24716 | proto.dayOfYear = getSetDayOfYear;
|
24717 | proto.hour = proto.hours = getSetHour;
|
24718 | proto.minute = proto.minutes = getSetMinute;
|
24719 | proto.second = proto.seconds = getSetSecond;
|
24720 | proto.millisecond = proto.milliseconds = getSetMillisecond;
|
24721 | proto.utcOffset = getSetOffset;
|
24722 | proto.utc = setOffsetToUTC;
|
24723 | proto.local = setOffsetToLocal;
|
24724 | proto.parseZone = setOffsetToParsedOffset;
|
24725 | proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
24726 | proto.isDST = isDaylightSavingTime;
|
24727 | proto.isLocal = isLocal;
|
24728 | proto.isUtcOffset = isUtcOffset;
|
24729 | proto.isUtc = isUtc;
|
24730 | proto.isUTC = isUtc;
|
24731 | proto.zoneAbbr = getZoneAbbr;
|
24732 | proto.zoneName = getZoneName;
|
24733 | proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
24734 | proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
24735 | proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
24736 | proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
|
24737 | proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
|
24738 |
|
24739 | function createUnix(input) {
|
24740 | return createLocal(input * 1000);
|
24741 | }
|
24742 |
|
24743 | function createInZone() {
|
24744 | return createLocal.apply(null, arguments).parseZone();
|
24745 | }
|
24746 |
|
24747 | function preParsePostFormat(string) {
|
24748 | return string;
|
24749 | }
|
24750 |
|
24751 | var proto$1 = Locale.prototype;
|
24752 | proto$1.calendar = calendar;
|
24753 | proto$1.longDateFormat = longDateFormat;
|
24754 | proto$1.invalidDate = invalidDate;
|
24755 | proto$1.ordinal = ordinal;
|
24756 | proto$1.preparse = preParsePostFormat;
|
24757 | proto$1.postformat = preParsePostFormat;
|
24758 | proto$1.relativeTime = relativeTime;
|
24759 | proto$1.pastFuture = pastFuture;
|
24760 | proto$1.set = set;
|
24761 | proto$1.months = localeMonths;
|
24762 | proto$1.monthsShort = localeMonthsShort;
|
24763 | proto$1.monthsParse = localeMonthsParse;
|
24764 | proto$1.monthsRegex = monthsRegex;
|
24765 | proto$1.monthsShortRegex = monthsShortRegex;
|
24766 | proto$1.week = localeWeek;
|
24767 | proto$1.firstDayOfYear = localeFirstDayOfYear;
|
24768 | proto$1.firstDayOfWeek = localeFirstDayOfWeek;
|
24769 | proto$1.weekdays = localeWeekdays;
|
24770 | proto$1.weekdaysMin = localeWeekdaysMin;
|
24771 | proto$1.weekdaysShort = localeWeekdaysShort;
|
24772 | proto$1.weekdaysParse = localeWeekdaysParse;
|
24773 | proto$1.weekdaysRegex = weekdaysRegex;
|
24774 | proto$1.weekdaysShortRegex = weekdaysShortRegex;
|
24775 | proto$1.weekdaysMinRegex = weekdaysMinRegex;
|
24776 | proto$1.isPM = localeIsPM;
|
24777 | proto$1.meridiem = localeMeridiem;
|
24778 |
|
24779 | function get$1(format, index, field, setter) {
|
24780 | var locale = getLocale();
|
24781 | var utc = createUTC().set(setter, index);
|
24782 | return locale[field](utc, format);
|
24783 | }
|
24784 |
|
24785 | function listMonthsImpl(format, index, field) {
|
24786 | if (isNumber(format)) {
|
24787 | index = format;
|
24788 | format = undefined;
|
24789 | }
|
24790 |
|
24791 | format = format || '';
|
24792 |
|
24793 | if (index != null) {
|
24794 | return get$1(format, index, field, 'month');
|
24795 | }
|
24796 |
|
24797 | var i;
|
24798 | var out = [];
|
24799 |
|
24800 | for (i = 0; i < 12; i++) {
|
24801 | out[i] = get$1(format, i, field, 'month');
|
24802 | }
|
24803 |
|
24804 | return out;
|
24805 | } // ()
|
24806 | // (5)
|
24807 | // (fmt, 5)
|
24808 | // (fmt)
|
24809 | // (true)
|
24810 | // (true, 5)
|
24811 | // (true, fmt, 5)
|
24812 | // (true, fmt)
|
24813 |
|
24814 |
|
24815 | function listWeekdaysImpl(localeSorted, format, index, field) {
|
24816 | if (typeof localeSorted === 'boolean') {
|
24817 | if (isNumber(format)) {
|
24818 | index = format;
|
24819 | format = undefined;
|
24820 | }
|
24821 |
|
24822 | format = format || '';
|
24823 | } else {
|
24824 | format = localeSorted;
|
24825 | index = format;
|
24826 | localeSorted = false;
|
24827 |
|
24828 | if (isNumber(format)) {
|
24829 | index = format;
|
24830 | format = undefined;
|
24831 | }
|
24832 |
|
24833 | format = format || '';
|
24834 | }
|
24835 |
|
24836 | var locale = getLocale(),
|
24837 | shift = localeSorted ? locale._week.dow : 0;
|
24838 |
|
24839 | if (index != null) {
|
24840 | return get$1(format, (index + shift) % 7, field, 'day');
|
24841 | }
|
24842 |
|
24843 | var i;
|
24844 | var out = [];
|
24845 |
|
24846 | for (i = 0; i < 7; i++) {
|
24847 | out[i] = get$1(format, (i + shift) % 7, field, 'day');
|
24848 | }
|
24849 |
|
24850 | return out;
|
24851 | }
|
24852 |
|
24853 | function listMonths(format, index) {
|
24854 | return listMonthsImpl(format, index, 'months');
|
24855 | }
|
24856 |
|
24857 | function listMonthsShort(format, index) {
|
24858 | return listMonthsImpl(format, index, 'monthsShort');
|
24859 | }
|
24860 |
|
24861 | function listWeekdays(localeSorted, format, index) {
|
24862 | return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
24863 | }
|
24864 |
|
24865 | function listWeekdaysShort(localeSorted, format, index) {
|
24866 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
24867 | }
|
24868 |
|
24869 | function listWeekdaysMin(localeSorted, format, index) {
|
24870 | return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
24871 | }
|
24872 |
|
24873 | getSetGlobalLocale('en', {
|
24874 | dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
|
24875 | ordinal: function (number) {
|
24876 | var b = number % 10,
|
24877 | output = toInt(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
|
24878 | return number + output;
|
24879 | }
|
24880 | });
|
24881 |
|
24882 | hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
|
24883 | hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
|
24884 | var mathAbs = Math.abs;
|
24885 |
|
24886 | function abs() {
|
24887 | var data = this._data;
|
24888 | this._milliseconds = mathAbs(this._milliseconds);
|
24889 | this._days = mathAbs(this._days);
|
24890 | this._months = mathAbs(this._months);
|
24891 | data.milliseconds = mathAbs(data.milliseconds);
|
24892 | data.seconds = mathAbs(data.seconds);
|
24893 | data.minutes = mathAbs(data.minutes);
|
24894 | data.hours = mathAbs(data.hours);
|
24895 | data.months = mathAbs(data.months);
|
24896 | data.years = mathAbs(data.years);
|
24897 | return this;
|
24898 | }
|
24899 |
|
24900 | function addSubtract$1(duration, input, value, direction) {
|
24901 | var other = createDuration(input, value);
|
24902 | duration._milliseconds += direction * other._milliseconds;
|
24903 | duration._days += direction * other._days;
|
24904 | duration._months += direction * other._months;
|
24905 | return duration._bubble();
|
24906 | }
|
24907 |
|
24908 |
|
24909 | function add$1(input, value) {
|
24910 | return addSubtract$1(this, input, value, 1);
|
24911 | }
|
24912 |
|
24913 |
|
24914 | function subtract$1(input, value) {
|
24915 | return addSubtract$1(this, input, value, -1);
|
24916 | }
|
24917 |
|
24918 | function absCeil(number) {
|
24919 | if (number < 0) {
|
24920 | return Math.floor(number);
|
24921 | } else {
|
24922 | return Math.ceil(number);
|
24923 | }
|
24924 | }
|
24925 |
|
24926 | function bubble() {
|
24927 | var milliseconds = this._milliseconds;
|
24928 | var days = this._days;
|
24929 | var months = this._months;
|
24930 | var data = this._data;
|
24931 | var seconds, minutes, hours, years, monthsFromDays;
|
24932 |
|
24933 |
|
24934 | if (!(milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0)) {
|
24935 | milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
|
24936 | days = 0;
|
24937 | months = 0;
|
24938 | }
|
24939 |
|
24940 |
|
24941 |
|
24942 | data.milliseconds = milliseconds % 1000;
|
24943 | seconds = absFloor(milliseconds / 1000);
|
24944 | data.seconds = seconds % 60;
|
24945 | minutes = absFloor(seconds / 60);
|
24946 | data.minutes = minutes % 60;
|
24947 | hours = absFloor(minutes / 60);
|
24948 | data.hours = hours % 24;
|
24949 | days += absFloor(hours / 24);
|
24950 |
|
24951 | monthsFromDays = absFloor(daysToMonths(days));
|
24952 | months += monthsFromDays;
|
24953 | days -= absCeil(monthsToDays(monthsFromDays));
|
24954 |
|
24955 | years = absFloor(months / 12);
|
24956 | months %= 12;
|
24957 | data.days = days;
|
24958 | data.months = months;
|
24959 | data.years = years;
|
24960 | return this;
|
24961 | }
|
24962 |
|
24963 | function daysToMonths(days) {
|
24964 |
|
24965 |
|
24966 | return days * 4800 / 146097;
|
24967 | }
|
24968 |
|
24969 | function monthsToDays(months) {
|
24970 |
|
24971 | return months * 146097 / 4800;
|
24972 | }
|
24973 |
|
24974 | function as(units) {
|
24975 | if (!this.isValid()) {
|
24976 | return NaN;
|
24977 | }
|
24978 |
|
24979 | var days;
|
24980 | var months;
|
24981 | var milliseconds = this._milliseconds;
|
24982 | units = normalizeUnits(units);
|
24983 |
|
24984 | if (units === 'month' || units === 'quarter' || units === 'year') {
|
24985 | days = this._days + milliseconds / 864e5;
|
24986 | months = this._months + daysToMonths(days);
|
24987 |
|
24988 | switch (units) {
|
24989 | case 'month':
|
24990 | return months;
|
24991 |
|
24992 | case 'quarter':
|
24993 | return months / 3;
|
24994 |
|
24995 | case 'year':
|
24996 | return months / 12;
|
24997 | }
|
24998 | } else {
|
24999 |
|
25000 | days = this._days + Math.round(monthsToDays(this._months));
|
25001 |
|
25002 | switch (units) {
|
25003 | case 'week':
|
25004 | return days / 7 + milliseconds / 6048e5;
|
25005 |
|
25006 | case 'day':
|
25007 | return days + milliseconds / 864e5;
|
25008 |
|
25009 | case 'hour':
|
25010 | return days * 24 + milliseconds / 36e5;
|
25011 |
|
25012 | case 'minute':
|
25013 | return days * 1440 + milliseconds / 6e4;
|
25014 |
|
25015 | case 'second':
|
25016 | return days * 86400 + milliseconds / 1000;
|
25017 |
|
25018 |
|
25019 | case 'millisecond':
|
25020 | return Math.floor(days * 864e5) + milliseconds;
|
25021 |
|
25022 | default:
|
25023 | throw new Error('Unknown unit ' + units);
|
25024 | }
|
25025 | }
|
25026 | }
|
25027 |
|
25028 |
|
25029 | function valueOf$1() {
|
25030 | if (!this.isValid()) {
|
25031 | return NaN;
|
25032 | }
|
25033 |
|
25034 | return this._milliseconds + this._days * 864e5 + this._months % 12 * 2592e6 + toInt(this._months / 12) * 31536e6;
|
25035 | }
|
25036 |
|
25037 | function makeAs(alias) {
|
25038 | return function () {
|
25039 | return this.as(alias);
|
25040 | };
|
25041 | }
|
25042 |
|
25043 | var asMilliseconds = makeAs('ms');
|
25044 | var asSeconds = makeAs('s');
|
25045 | var asMinutes = makeAs('m');
|
25046 | var asHours = makeAs('h');
|
25047 | var asDays = makeAs('d');
|
25048 | var asWeeks = makeAs('w');
|
25049 | var asMonths = makeAs('M');
|
25050 | var asQuarters = makeAs('Q');
|
25051 | var asYears = makeAs('y');
|
25052 |
|
25053 | function clone$1() {
|
25054 | return createDuration(this);
|
25055 | }
|
25056 |
|
25057 | function get$2(units) {
|
25058 | units = normalizeUnits(units);
|
25059 | return this.isValid() ? this[units + 's']() : NaN;
|
25060 | }
|
25061 |
|
25062 | function makeGetter(name) {
|
25063 | return function () {
|
25064 | return this.isValid() ? this._data[name] : NaN;
|
25065 | };
|
25066 | }
|
25067 |
|
25068 | var milliseconds = makeGetter('milliseconds');
|
25069 | var seconds = makeGetter('seconds');
|
25070 | var minutes = makeGetter('minutes');
|
25071 | var hours = makeGetter('hours');
|
25072 | var days = makeGetter('days');
|
25073 | var months = makeGetter('months');
|
25074 | var years = makeGetter('years');
|
25075 |
|
25076 | function weeks() {
|
25077 | return absFloor(this.days() / 7);
|
25078 | }
|
25079 |
|
25080 | var round = Math.round;
|
25081 | var thresholds = {
|
25082 | ss: 44,
|
25083 |
|
25084 | s: 45,
|
25085 |
|
25086 | m: 45,
|
25087 |
|
25088 | h: 22,
|
25089 |
|
25090 | d: 26,
|
25091 |
|
25092 | M: 11
|
25093 |
|
25094 | };
|
25095 |
|
25096 | function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
25097 | return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
25098 | }
|
25099 |
|
25100 | function relativeTime$1(posNegDuration, withoutSuffix, locale) {
|
25101 | var duration = createDuration(posNegDuration).abs();
|
25102 | var seconds = round(duration.as('s'));
|
25103 | var minutes = round(duration.as('m'));
|
25104 | var hours = round(duration.as('h'));
|
25105 | var days = round(duration.as('d'));
|
25106 | var months = round(duration.as('M'));
|
25107 | var years = round(duration.as('y'));
|
25108 | var a = seconds <= thresholds.ss && ['s', seconds] || seconds < thresholds.s && ['ss', seconds] || minutes <= 1 && ['m'] || minutes < thresholds.m && ['mm', minutes] || hours <= 1 && ['h'] || hours < thresholds.h && ['hh', hours] || days <= 1 && ['d'] || days < thresholds.d && ['dd', days] || months <= 1 && ['M'] || months < thresholds.M && ['MM', months] || years <= 1 && ['y'] || ['yy', years];
|
25109 | a[2] = withoutSuffix;
|
25110 | a[3] = +posNegDuration > 0;
|
25111 | a[4] = locale;
|
25112 | return substituteTimeAgo.apply(null, a);
|
25113 | }
|
25114 |
|
25115 |
|
25116 | function getSetRelativeTimeRounding(roundingFunction) {
|
25117 | if (roundingFunction === undefined) {
|
25118 | return round;
|
25119 | }
|
25120 |
|
25121 | if (typeof roundingFunction === 'function') {
|
25122 | round = roundingFunction;
|
25123 | return true;
|
25124 | }
|
25125 |
|
25126 | return false;
|
25127 | }
|
25128 |
|
25129 |
|
25130 | function getSetRelativeTimeThreshold(threshold, limit) {
|
25131 | if (thresholds[threshold] === undefined) {
|
25132 | return false;
|
25133 | }
|
25134 |
|
25135 | if (limit === undefined) {
|
25136 | return thresholds[threshold];
|
25137 | }
|
25138 |
|
25139 | thresholds[threshold] = limit;
|
25140 |
|
25141 | if (threshold === 's') {
|
25142 | thresholds.ss = limit - 1;
|
25143 | }
|
25144 |
|
25145 | return true;
|
25146 | }
|
25147 |
|
25148 | function humanize(withSuffix) {
|
25149 | if (!this.isValid()) {
|
25150 | return this.localeData().invalidDate();
|
25151 | }
|
25152 |
|
25153 | var locale = this.localeData();
|
25154 | var output = relativeTime$1(this, !withSuffix, locale);
|
25155 |
|
25156 | if (withSuffix) {
|
25157 | output = locale.pastFuture(+this, output);
|
25158 | }
|
25159 |
|
25160 | return locale.postformat(output);
|
25161 | }
|
25162 |
|
25163 | var abs$1 = Math.abs;
|
25164 |
|
25165 | function sign(x) {
|
25166 | return (x > 0) - (x < 0) || +x;
|
25167 | }
|
25168 |
|
25169 | function toISOString$1() {
|
25170 |
|
25171 |
|
25172 |
|
25173 |
|
25174 |
|
25175 |
|
25176 |
|
25177 | if (!this.isValid()) {
|
25178 | return this.localeData().invalidDate();
|
25179 | }
|
25180 |
|
25181 | var seconds = abs$1(this._milliseconds) / 1000;
|
25182 | var days = abs$1(this._days);
|
25183 | var months = abs$1(this._months);
|
25184 | var minutes, hours, years;
|
25185 |
|
25186 | minutes = absFloor(seconds / 60);
|
25187 | hours = absFloor(minutes / 60);
|
25188 | seconds %= 60;
|
25189 | minutes %= 60;
|
25190 |
|
25191 | years = absFloor(months / 12);
|
25192 | months %= 12;
|
25193 |
|
25194 | var Y = years;
|
25195 | var M = months;
|
25196 | var D = days;
|
25197 | var h = hours;
|
25198 | var m = minutes;
|
25199 | var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
|
25200 | var total = this.asSeconds();
|
25201 |
|
25202 | if (!total) {
|
25203 |
|
25204 |
|
25205 | return 'P0D';
|
25206 | }
|
25207 |
|
25208 | var totalSign = total < 0 ? '-' : '';
|
25209 | var ymSign = sign(this._months) !== sign(total) ? '-' : '';
|
25210 | var daysSign = sign(this._days) !== sign(total) ? '-' : '';
|
25211 | var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
|
25212 | return totalSign + 'P' + (Y ? ymSign + Y + 'Y' : '') + (M ? ymSign + M + 'M' : '') + (D ? daysSign + D + 'D' : '') + (h || m || s ? 'T' : '') + (h ? hmsSign + h + 'H' : '') + (m ? hmsSign + m + 'M' : '') + (s ? hmsSign + s + 'S' : '');
|
25213 | }
|
25214 |
|
25215 | var proto$2 = Duration.prototype;
|
25216 | proto$2.isValid = isValid$1;
|
25217 | proto$2.abs = abs;
|
25218 | proto$2.add = add$1;
|
25219 | proto$2.subtract = subtract$1;
|
25220 | proto$2.as = as;
|
25221 | proto$2.asMilliseconds = asMilliseconds;
|
25222 | proto$2.asSeconds = asSeconds;
|
25223 | proto$2.asMinutes = asMinutes;
|
25224 | proto$2.asHours = asHours;
|
25225 | proto$2.asDays = asDays;
|
25226 | proto$2.asWeeks = asWeeks;
|
25227 | proto$2.asMonths = asMonths;
|
25228 | proto$2.asQuarters = asQuarters;
|
25229 | proto$2.asYears = asYears;
|
25230 | proto$2.valueOf = valueOf$1;
|
25231 | proto$2._bubble = bubble;
|
25232 | proto$2.clone = clone$1;
|
25233 | proto$2.get = get$2;
|
25234 | proto$2.milliseconds = milliseconds;
|
25235 | proto$2.seconds = seconds;
|
25236 | proto$2.minutes = minutes;
|
25237 | proto$2.hours = hours;
|
25238 | proto$2.days = days;
|
25239 | proto$2.weeks = weeks;
|
25240 | proto$2.months = months;
|
25241 | proto$2.years = years;
|
25242 | proto$2.humanize = humanize;
|
25243 | proto$2.toISOString = toISOString$1;
|
25244 | proto$2.toString = toISOString$1;
|
25245 | proto$2.toJSON = toISOString$1;
|
25246 | proto$2.locale = locale;
|
25247 | proto$2.localeData = localeData;
|
25248 | proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
|
25249 | proto$2.lang = lang; // Side effect imports
|
25250 | // FORMATTING
|
25251 |
|
25252 | addFormatToken('X', 0, 0, 'unix');
|
25253 | addFormatToken('x', 0, 0, 'valueOf'); // PARSING
|
25254 |
|
25255 | addRegexToken('x', matchSigned);
|
25256 | addRegexToken('X', matchTimestamp);
|
25257 | addParseToken('X', function (input, array, config) {
|
25258 | config._d = new Date(parseFloat(input, 10) * 1000);
|
25259 | });
|
25260 | addParseToken('x', function (input, array, config) {
|
25261 | config._d = new Date(toInt(input));
|
25262 | });
|
25263 |
|
25264 | hooks.version = '2.24.0';
|
25265 | setHookCallback(createLocal);
|
25266 | hooks.fn = proto;
|
25267 | hooks.min = min;
|
25268 | hooks.max = max;
|
25269 | hooks.now = now;
|
25270 | hooks.utc = createUTC;
|
25271 | hooks.unix = createUnix;
|
25272 | hooks.months = listMonths;
|
25273 | hooks.isDate = isDate;
|
25274 | hooks.locale = getSetGlobalLocale;
|
25275 | hooks.invalid = createInvalid;
|
25276 | hooks.duration = createDuration;
|
25277 | hooks.isMoment = isMoment;
|
25278 | hooks.weekdays = listWeekdays;
|
25279 | hooks.parseZone = createInZone;
|
25280 | hooks.localeData = getLocale;
|
25281 | hooks.isDuration = isDuration;
|
25282 | hooks.monthsShort = listMonthsShort;
|
25283 | hooks.weekdaysMin = listWeekdaysMin;
|
25284 | hooks.defineLocale = defineLocale;
|
25285 | hooks.updateLocale = updateLocale;
|
25286 | hooks.locales = listLocales;
|
25287 | hooks.weekdaysShort = listWeekdaysShort;
|
25288 | hooks.normalizeUnits = normalizeUnits;
|
25289 | hooks.relativeTimeRounding = getSetRelativeTimeRounding;
|
25290 | hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
|
25291 | hooks.calendarFormat = getCalendarFormat;
|
25292 | hooks.prototype = proto;
|
25293 |
|
25294 | hooks.HTML5_FMT = {
|
25295 | DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm',
|
25296 |
|
25297 | DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss',
|
25298 |
|
25299 | DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS',
|
25300 |
|
25301 | DATE: 'YYYY-MM-DD',
|
25302 |
|
25303 | TIME: 'HH:mm',
|
25304 |
|
25305 | TIME_SECONDS: 'HH:mm:ss',
|
25306 |
|
25307 | TIME_MS: 'HH:mm:ss.SSS',
|
25308 |
|
25309 | WEEK: 'GGGG-[W]WW',
|
25310 |
|
25311 | MONTH: 'YYYY-MM'
|
25312 |
|
25313 | };
|
25314 | return hooks;
|
25315 | });
|
25316 | });
|
25317 |
|
25318 |
|
25319 |
|
25320 | var moment$3 = typeof window !== 'undefined' && window['moment'] || moment$2;
|
25321 |
|
25322 | var propagating = createCommonjsModule$1(function (module, exports) {
|
25323 |
|
25324 | (function (factory) {
|
25325 | {
|
25326 |
|
25327 |
|
25328 |
|
25329 | module.exports = factory();
|
25330 | }
|
25331 | })(function () {
|
25332 | var _firstTarget = null;
|
25333 |
|
25334 | |
25335 |
|
25336 |
|
25337 |
|
25338 |
|
25339 |
|
25340 |
|
25341 |
|
25342 |
|
25343 |
|
25344 |
|
25345 |
|
25346 |
|
25347 |
|
25348 |
|
25349 |
|
25350 |
|
25351 |
|
25352 |
|
25353 |
|
25354 |
|
25355 |
|
25356 |
|
25357 | return function propagating(hammer, options) {
|
25358 | var _options = options || {
|
25359 | preventDefault: false
|
25360 | };
|
25361 |
|
25362 | if (hammer.Manager) {
|
25363 |
|
25364 |
|
25365 | var Hammer = hammer;
|
25366 |
|
25367 | var PropagatingHammer = function (element, options) {
|
25368 | var o = Object.create(_options);
|
25369 | if (options) Hammer.assign(o, options);
|
25370 | return propagating(new Hammer(element, o), o);
|
25371 | };
|
25372 |
|
25373 | Hammer.assign(PropagatingHammer, Hammer);
|
25374 |
|
25375 | PropagatingHammer.Manager = function (element, options) {
|
25376 | var o = Object.create(_options);
|
25377 | if (options) Hammer.assign(o, options);
|
25378 | return propagating(new Hammer.Manager(element, o), o);
|
25379 | };
|
25380 |
|
25381 | return PropagatingHammer;
|
25382 | }
|
25383 |
|
25384 |
|
25385 |
|
25386 | var wrapper = Object.create(hammer);
|
25387 |
|
25388 | var element = hammer.element;
|
25389 | if (!element.hammer) element.hammer = [];
|
25390 | element.hammer.push(wrapper);
|
25391 |
|
25392 |
|
25393 | hammer.on('hammer.input', function (event) {
|
25394 | if (_options.preventDefault === true || _options.preventDefault === event.pointerType) {
|
25395 | event.preventDefault();
|
25396 | }
|
25397 |
|
25398 | if (event.isFirst) {
|
25399 | _firstTarget = event.target;
|
25400 | }
|
25401 | });
|
25402 |
|
25403 |
|
25404 | wrapper._handlers = {};
|
25405 | |
25406 |
|
25407 |
|
25408 |
|
25409 |
|
25410 |
|
25411 |
|
25412 | wrapper.on = function (events, handler) {
|
25413 |
|
25414 | split(events).forEach(function (event) {
|
25415 | var _handlers = wrapper._handlers[event];
|
25416 |
|
25417 | if (!_handlers) {
|
25418 | wrapper._handlers[event] = _handlers = [];
|
25419 |
|
25420 | hammer.on(event, propagatedHandler);
|
25421 | }
|
25422 |
|
25423 | _handlers.push(handler);
|
25424 | });
|
25425 | return wrapper;
|
25426 | };
|
25427 | |
25428 |
|
25429 |
|
25430 |
|
25431 |
|
25432 |
|
25433 |
|
25434 |
|
25435 |
|
25436 |
|
25437 | wrapper.off = function (events, handler) {
|
25438 |
|
25439 | split(events).forEach(function (event) {
|
25440 | var _handlers = wrapper._handlers[event];
|
25441 |
|
25442 | if (_handlers) {
|
25443 | _handlers = handler ? _handlers.filter(function (h) {
|
25444 | return h !== handler;
|
25445 | }) : [];
|
25446 |
|
25447 | if (_handlers.length > 0) {
|
25448 | wrapper._handlers[event] = _handlers;
|
25449 | } else {
|
25450 |
|
25451 | hammer.off(event, propagatedHandler);
|
25452 | delete wrapper._handlers[event];
|
25453 | }
|
25454 | }
|
25455 | });
|
25456 | return wrapper;
|
25457 | };
|
25458 | |
25459 |
|
25460 |
|
25461 |
|
25462 |
|
25463 |
|
25464 |
|
25465 | wrapper.emit = function (eventType, event) {
|
25466 | _firstTarget = event.target;
|
25467 | hammer.emit(eventType, event);
|
25468 | };
|
25469 |
|
25470 | wrapper.destroy = function () {
|
25471 |
|
25472 | var hammers = hammer.element.hammer;
|
25473 | var idx = hammers.indexOf(wrapper);
|
25474 | if (idx !== -1) hammers.splice(idx, 1);
|
25475 | if (!hammers.length) delete hammer.element.hammer;
|
25476 |
|
25477 | wrapper._handlers = {};
|
25478 |
|
25479 | hammer.destroy();
|
25480 | };
|
25481 |
|
25482 |
|
25483 | function split(events) {
|
25484 | return events.match(/[^ ]+/g);
|
25485 | }
|
25486 | |
25487 |
|
25488 |
|
25489 |
|
25490 |
|
25491 |
|
25492 | function propagatedHandler(event) {
|
25493 |
|
25494 | if (event.type !== 'hammer.input') {
|
25495 |
|
25496 |
|
25497 | if (!event.srcEvent._handled) {
|
25498 | event.srcEvent._handled = {};
|
25499 | }
|
25500 |
|
25501 | if (event.srcEvent._handled[event.type]) {
|
25502 | return;
|
25503 | } else {
|
25504 | event.srcEvent._handled[event.type] = true;
|
25505 | }
|
25506 | }
|
25507 |
|
25508 |
|
25509 | var stopped = false;
|
25510 |
|
25511 | event.stopPropagation = function () {
|
25512 | stopped = true;
|
25513 | };
|
25514 |
|
25515 |
|
25516 | var srcStop = event.srcEvent.stopPropagation.bind(event.srcEvent);
|
25517 |
|
25518 | if (typeof srcStop == "function") {
|
25519 | event.srcEvent.stopPropagation = function () {
|
25520 | srcStop();
|
25521 | event.stopPropagation();
|
25522 | };
|
25523 | }
|
25524 |
|
25525 |
|
25526 | event.firstTarget = _firstTarget;
|
25527 |
|
25528 | var elem = _firstTarget;
|
25529 |
|
25530 | while (elem && !stopped) {
|
25531 | var elemHammer = elem.hammer;
|
25532 |
|
25533 | if (elemHammer) {
|
25534 | var _handlers;
|
25535 |
|
25536 | for (var k = 0; k < elemHammer.length; k++) {
|
25537 | _handlers = elemHammer[k]._handlers[event.type];
|
25538 | if (_handlers) for (var i = 0; i < _handlers.length && !stopped; i++) {
|
25539 | _handlers[i](event);
|
25540 | }
|
25541 | }
|
25542 | }
|
25543 |
|
25544 | elem = elem.parentNode;
|
25545 | }
|
25546 | }
|
25547 |
|
25548 | return wrapper;
|
25549 | };
|
25550 | });
|
25551 | });
|
25552 |
|
25553 | var hammer = createCommonjsModule$1(function (module) {
|
25554 | |
25555 |
|
25556 |
|
25557 |
|
25558 |
|
25559 | (function (window, document, exportName, undefined$1) {
|
25560 |
|
25561 | var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
25562 | var TEST_ELEMENT = document.createElement('div');
|
25563 | var TYPE_FUNCTION = 'function';
|
25564 | var round = Math.round;
|
25565 | var abs = Math.abs;
|
25566 | var now = Date.now;
|
25567 | |
25568 |
|
25569 |
|
25570 |
|
25571 |
|
25572 |
|
25573 |
|
25574 |
|
25575 | function setTimeoutContext(fn, timeout, context) {
|
25576 | return setTimeout(bindFn(fn, context), timeout);
|
25577 | }
|
25578 | |
25579 |
|
25580 |
|
25581 |
|
25582 |
|
25583 |
|
25584 |
|
25585 |
|
25586 |
|
25587 |
|
25588 |
|
25589 | function invokeArrayArg(arg, fn, context) {
|
25590 | if (Array.isArray(arg)) {
|
25591 | each(arg, context[fn], context);
|
25592 | return true;
|
25593 | }
|
25594 |
|
25595 | return false;
|
25596 | }
|
25597 | |
25598 |
|
25599 |
|
25600 |
|
25601 |
|
25602 |
|
25603 |
|
25604 |
|
25605 | function each(obj, iterator, context) {
|
25606 | var i;
|
25607 |
|
25608 | if (!obj) {
|
25609 | return;
|
25610 | }
|
25611 |
|
25612 | if (obj.forEach) {
|
25613 | obj.forEach(iterator, context);
|
25614 | } else if (obj.length !== undefined$1) {
|
25615 | i = 0;
|
25616 |
|
25617 | while (i < obj.length) {
|
25618 | iterator.call(context, obj[i], i, obj);
|
25619 | i++;
|
25620 | }
|
25621 | } else {
|
25622 | for (i in obj) {
|
25623 | obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
25624 | }
|
25625 | }
|
25626 | }
|
25627 | |
25628 |
|
25629 |
|
25630 |
|
25631 |
|
25632 |
|
25633 |
|
25634 |
|
25635 |
|
25636 | function deprecate(method, name, message) {
|
25637 | var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
25638 | return function () {
|
25639 | var e = new Error('get-stack-trace');
|
25640 | var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '').replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
|
25641 | var log = window.console && (window.console.warn || window.console.log);
|
25642 |
|
25643 | if (log) {
|
25644 | log.call(window.console, deprecationMessage, stack);
|
25645 | }
|
25646 |
|
25647 | return method.apply(this, arguments);
|
25648 | };
|
25649 | }
|
25650 | |
25651 |
|
25652 |
|
25653 |
|
25654 |
|
25655 |
|
25656 |
|
25657 |
|
25658 |
|
25659 | var assign;
|
25660 |
|
25661 | if (typeof Object.assign !== 'function') {
|
25662 | assign = function assign(target) {
|
25663 | if (target === undefined$1 || target === null) {
|
25664 | throw new TypeError('Cannot convert undefined or null to object');
|
25665 | }
|
25666 |
|
25667 | var output = Object(target);
|
25668 |
|
25669 | for (var index = 1; index < arguments.length; index++) {
|
25670 | var source = arguments[index];
|
25671 |
|
25672 | if (source !== undefined$1 && source !== null) {
|
25673 | for (var nextKey in source) {
|
25674 | if (source.hasOwnProperty(nextKey)) {
|
25675 | output[nextKey] = source[nextKey];
|
25676 | }
|
25677 | }
|
25678 | }
|
25679 | }
|
25680 |
|
25681 | return output;
|
25682 | };
|
25683 | } else {
|
25684 | assign = Object.assign;
|
25685 | }
|
25686 | |
25687 |
|
25688 |
|
25689 |
|
25690 |
|
25691 |
|
25692 |
|
25693 |
|
25694 |
|
25695 |
|
25696 | var extend = deprecate(function extend(dest, src, merge) {
|
25697 | var keys = Object.keys(src);
|
25698 | var i = 0;
|
25699 |
|
25700 | while (i < keys.length) {
|
25701 | if (!merge || merge && dest[keys[i]] === undefined$1) {
|
25702 | dest[keys[i]] = src[keys[i]];
|
25703 | }
|
25704 |
|
25705 | i++;
|
25706 | }
|
25707 |
|
25708 | return dest;
|
25709 | }, 'extend', 'Use `assign`.');
|
25710 | |
25711 |
|
25712 |
|
25713 |
|
25714 |
|
25715 |
|
25716 |
|
25717 |
|
25718 | var merge = deprecate(function merge(dest, src) {
|
25719 | return extend(dest, src, true);
|
25720 | }, 'merge', 'Use `assign`.');
|
25721 | |
25722 |
|
25723 |
|
25724 |
|
25725 |
|
25726 |
|
25727 |
|
25728 | function inherit(child, base, properties) {
|
25729 | var baseP = base.prototype,
|
25730 | childP;
|
25731 | childP = child.prototype = Object.create(baseP);
|
25732 | childP.constructor = child;
|
25733 | childP._super = baseP;
|
25734 |
|
25735 | if (properties) {
|
25736 | assign(childP, properties);
|
25737 | }
|
25738 | }
|
25739 | |
25740 |
|
25741 |
|
25742 |
|
25743 |
|
25744 |
|
25745 |
|
25746 |
|
25747 | function bindFn(fn, context) {
|
25748 | return function boundFn() {
|
25749 | return fn.apply(context, arguments);
|
25750 | };
|
25751 | }
|
25752 | |
25753 |
|
25754 |
|
25755 |
|
25756 |
|
25757 |
|
25758 |
|
25759 |
|
25760 |
|
25761 | function boolOrFn(val, args) {
|
25762 | if (typeof val == TYPE_FUNCTION) {
|
25763 | return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
|
25764 | }
|
25765 |
|
25766 | return val;
|
25767 | }
|
25768 | |
25769 |
|
25770 |
|
25771 |
|
25772 |
|
25773 |
|
25774 |
|
25775 |
|
25776 | function ifUndefined(val1, val2) {
|
25777 | return val1 === undefined$1 ? val2 : val1;
|
25778 | }
|
25779 | |
25780 |
|
25781 |
|
25782 |
|
25783 |
|
25784 |
|
25785 |
|
25786 |
|
25787 | function addEventListeners(target, types, handler) {
|
25788 | each(splitStr(types), function (type) {
|
25789 | target.addEventListener(type, handler, false);
|
25790 | });
|
25791 | }
|
25792 | |
25793 |
|
25794 |
|
25795 |
|
25796 |
|
25797 |
|
25798 |
|
25799 |
|
25800 | function removeEventListeners(target, types, handler) {
|
25801 | each(splitStr(types), function (type) {
|
25802 | target.removeEventListener(type, handler, false);
|
25803 | });
|
25804 | }
|
25805 | |
25806 |
|
25807 |
|
25808 |
|
25809 |
|
25810 |
|
25811 |
|
25812 |
|
25813 |
|
25814 | function hasParent(node, parent) {
|
25815 | while (node) {
|
25816 | if (node == parent) {
|
25817 | return true;
|
25818 | }
|
25819 |
|
25820 | node = node.parentNode;
|
25821 | }
|
25822 |
|
25823 | return false;
|
25824 | }
|
25825 | |
25826 |
|
25827 |
|
25828 |
|
25829 |
|
25830 |
|
25831 |
|
25832 |
|
25833 | function inStr(str, find) {
|
25834 | return str.indexOf(find) > -1;
|
25835 | }
|
25836 | |
25837 |
|
25838 |
|
25839 |
|
25840 |
|
25841 |
|
25842 |
|
25843 | function splitStr(str) {
|
25844 | return str.trim().split(/\s+/g);
|
25845 | }
|
25846 | |
25847 |
|
25848 |
|
25849 |
|
25850 |
|
25851 |
|
25852 |
|
25853 |
|
25854 |
|
25855 | function inArray(src, find, findByKey) {
|
25856 | if (src.indexOf && !findByKey) {
|
25857 | return src.indexOf(find);
|
25858 | } else {
|
25859 | var i = 0;
|
25860 |
|
25861 | while (i < src.length) {
|
25862 | if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
|
25863 | return i;
|
25864 | }
|
25865 |
|
25866 | i++;
|
25867 | }
|
25868 |
|
25869 | return -1;
|
25870 | }
|
25871 | }
|
25872 | |
25873 |
|
25874 |
|
25875 |
|
25876 |
|
25877 |
|
25878 |
|
25879 | function toArray(obj) {
|
25880 | return Array.prototype.slice.call(obj, 0);
|
25881 | }
|
25882 | |
25883 |
|
25884 |
|
25885 |
|
25886 |
|
25887 |
|
25888 |
|
25889 |
|
25890 |
|
25891 | function uniqueArray(src, key, sort) {
|
25892 | var results = [];
|
25893 | var values = [];
|
25894 | var i = 0;
|
25895 |
|
25896 | while (i < src.length) {
|
25897 | var val = key ? src[i][key] : src[i];
|
25898 |
|
25899 | if (inArray(values, val) < 0) {
|
25900 | results.push(src[i]);
|
25901 | }
|
25902 |
|
25903 | values[i] = val;
|
25904 | i++;
|
25905 | }
|
25906 |
|
25907 | if (sort) {
|
25908 | if (!key) {
|
25909 | results = results.sort();
|
25910 | } else {
|
25911 | results = results.sort(function sortUniqueArray(a, b) {
|
25912 | return a[key] > b[key];
|
25913 | });
|
25914 | }
|
25915 | }
|
25916 |
|
25917 | return results;
|
25918 | }
|
25919 | |
25920 |
|
25921 |
|
25922 |
|
25923 |
|
25924 |
|
25925 |
|
25926 |
|
25927 | function prefixed(obj, property) {
|
25928 | var prefix, prop;
|
25929 | var camelProp = property[0].toUpperCase() + property.slice(1);
|
25930 | var i = 0;
|
25931 |
|
25932 | while (i < VENDOR_PREFIXES.length) {
|
25933 | prefix = VENDOR_PREFIXES[i];
|
25934 | prop = prefix ? prefix + camelProp : property;
|
25935 |
|
25936 | if (prop in obj) {
|
25937 | return prop;
|
25938 | }
|
25939 |
|
25940 | i++;
|
25941 | }
|
25942 |
|
25943 | return undefined$1;
|
25944 | }
|
25945 | |
25946 |
|
25947 |
|
25948 |
|
25949 |
|
25950 |
|
25951 | var _uniqueId = 1;
|
25952 |
|
25953 | function uniqueId() {
|
25954 | return _uniqueId++;
|
25955 | }
|
25956 | |
25957 |
|
25958 |
|
25959 |
|
25960 |
|
25961 |
|
25962 |
|
25963 | function getWindowForElement(element) {
|
25964 | var doc = element.ownerDocument || element;
|
25965 | return doc.defaultView || doc.parentWindow || window;
|
25966 | }
|
25967 |
|
25968 | var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
25969 | var SUPPORT_TOUCH = 'ontouchstart' in window;
|
25970 | var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined$1;
|
25971 | var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
25972 | var INPUT_TYPE_TOUCH = 'touch';
|
25973 | var INPUT_TYPE_PEN = 'pen';
|
25974 | var INPUT_TYPE_MOUSE = 'mouse';
|
25975 | var INPUT_TYPE_KINECT = 'kinect';
|
25976 | var COMPUTE_INTERVAL = 25;
|
25977 | var INPUT_START = 1;
|
25978 | var INPUT_MOVE = 2;
|
25979 | var INPUT_END = 4;
|
25980 | var INPUT_CANCEL = 8;
|
25981 | var DIRECTION_NONE = 1;
|
25982 | var DIRECTION_LEFT = 2;
|
25983 | var DIRECTION_RIGHT = 4;
|
25984 | var DIRECTION_UP = 8;
|
25985 | var DIRECTION_DOWN = 16;
|
25986 | var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
25987 | var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
25988 | var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
25989 | var PROPS_XY = ['x', 'y'];
|
25990 | var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
25991 | |
25992 |
|
25993 |
|
25994 |
|
25995 |
|
25996 |
|
25997 |
|
25998 |
|
25999 | function Input(manager, callback) {
|
26000 | var self = this;
|
26001 | this.manager = manager;
|
26002 | this.callback = callback;
|
26003 | this.element = manager.element;
|
26004 | this.target = manager.options.inputTarget;
|
26005 |
|
26006 |
|
26007 | this.domHandler = function (ev) {
|
26008 | if (boolOrFn(manager.options.enable, [manager])) {
|
26009 | self.handler(ev);
|
26010 | }
|
26011 | };
|
26012 |
|
26013 | this.init();
|
26014 | }
|
26015 |
|
26016 | Input.prototype = {
|
26017 | |
26018 |
|
26019 |
|
26020 |
|
26021 | handler: function () {},
|
26022 |
|
26023 | |
26024 |
|
26025 |
|
26026 | init: function () {
|
26027 | this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
26028 | this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
26029 | this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
26030 | },
|
26031 |
|
26032 | |
26033 |
|
26034 |
|
26035 | destroy: function () {
|
26036 | this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
26037 | this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
26038 | this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
26039 | }
|
26040 | };
|
26041 | |
26042 |
|
26043 |
|
26044 |
|
26045 |
|
26046 |
|
26047 |
|
26048 | function createInputInstance(manager) {
|
26049 | var Type;
|
26050 | var inputClass = manager.options.inputClass;
|
26051 |
|
26052 | if (inputClass) {
|
26053 | Type = inputClass;
|
26054 | } else if (SUPPORT_POINTER_EVENTS) {
|
26055 | Type = PointerEventInput;
|
26056 | } else if (SUPPORT_ONLY_TOUCH) {
|
26057 | Type = TouchInput;
|
26058 | } else if (!SUPPORT_TOUCH) {
|
26059 | Type = MouseInput;
|
26060 | } else {
|
26061 | Type = TouchMouseInput;
|
26062 | }
|
26063 |
|
26064 | return new Type(manager, inputHandler);
|
26065 | }
|
26066 | |
26067 |
|
26068 |
|
26069 |
|
26070 |
|
26071 |
|
26072 |
|
26073 |
|
26074 | function inputHandler(manager, eventType, input) {
|
26075 | var pointersLen = input.pointers.length;
|
26076 | var changedPointersLen = input.changedPointers.length;
|
26077 | var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
|
26078 | var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
|
26079 | input.isFirst = !!isFirst;
|
26080 | input.isFinal = !!isFinal;
|
26081 |
|
26082 | if (isFirst) {
|
26083 | manager.session = {};
|
26084 | }
|
26085 |
|
26086 |
|
26087 |
|
26088 | input.eventType = eventType;
|
26089 |
|
26090 | computeInputData(manager, input);
|
26091 |
|
26092 | manager.emit('hammer.input', input);
|
26093 | manager.recognize(input);
|
26094 | manager.session.prevInput = input;
|
26095 | }
|
26096 | |
26097 |
|
26098 |
|
26099 |
|
26100 |
|
26101 |
|
26102 |
|
26103 | function computeInputData(manager, input) {
|
26104 | var session = manager.session;
|
26105 | var pointers = input.pointers;
|
26106 | var pointersLength = pointers.length;
|
26107 |
|
26108 | if (!session.firstInput) {
|
26109 | session.firstInput = simpleCloneInputData(input);
|
26110 | }
|
26111 |
|
26112 |
|
26113 | if (pointersLength > 1 && !session.firstMultiple) {
|
26114 | session.firstMultiple = simpleCloneInputData(input);
|
26115 | } else if (pointersLength === 1) {
|
26116 | session.firstMultiple = false;
|
26117 | }
|
26118 |
|
26119 | var firstInput = session.firstInput;
|
26120 | var firstMultiple = session.firstMultiple;
|
26121 | var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
26122 | var center = input.center = getCenter(pointers);
|
26123 | input.timeStamp = now();
|
26124 | input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
26125 | input.angle = getAngle(offsetCenter, center);
|
26126 | input.distance = getDistance(offsetCenter, center);
|
26127 | computeDeltaXY(session, input);
|
26128 | input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
26129 | var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
26130 | input.overallVelocityX = overallVelocity.x;
|
26131 | input.overallVelocityY = overallVelocity.y;
|
26132 | input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
|
26133 | input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
26134 | input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
26135 | input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
|
26136 | computeIntervalInputData(session, input);
|
26137 |
|
26138 | var target = manager.element;
|
26139 |
|
26140 | if (hasParent(input.srcEvent.target, target)) {
|
26141 | target = input.srcEvent.target;
|
26142 | }
|
26143 |
|
26144 | input.target = target;
|
26145 | }
|
26146 |
|
26147 | function computeDeltaXY(session, input) {
|
26148 | var center = input.center;
|
26149 | var offset = session.offsetDelta || {};
|
26150 | var prevDelta = session.prevDelta || {};
|
26151 | var prevInput = session.prevInput || {};
|
26152 |
|
26153 | if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
26154 | prevDelta = session.prevDelta = {
|
26155 | x: prevInput.deltaX || 0,
|
26156 | y: prevInput.deltaY || 0
|
26157 | };
|
26158 | offset = session.offsetDelta = {
|
26159 | x: center.x,
|
26160 | y: center.y
|
26161 | };
|
26162 | }
|
26163 |
|
26164 | input.deltaX = prevDelta.x + (center.x - offset.x);
|
26165 | input.deltaY = prevDelta.y + (center.y - offset.y);
|
26166 | }
|
26167 | |
26168 |
|
26169 |
|
26170 |
|
26171 |
|
26172 |
|
26173 |
|
26174 | function computeIntervalInputData(session, input) {
|
26175 | var last = session.lastInterval || input,
|
26176 | deltaTime = input.timeStamp - last.timeStamp,
|
26177 | velocity,
|
26178 | velocityX,
|
26179 | velocityY,
|
26180 | direction;
|
26181 |
|
26182 | if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
|
26183 | var deltaX = input.deltaX - last.deltaX;
|
26184 | var deltaY = input.deltaY - last.deltaY;
|
26185 | var v = getVelocity(deltaTime, deltaX, deltaY);
|
26186 | velocityX = v.x;
|
26187 | velocityY = v.y;
|
26188 | velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
|
26189 | direction = getDirection(deltaX, deltaY);
|
26190 | session.lastInterval = input;
|
26191 | } else {
|
26192 |
|
26193 | velocity = last.velocity;
|
26194 | velocityX = last.velocityX;
|
26195 | velocityY = last.velocityY;
|
26196 | direction = last.direction;
|
26197 | }
|
26198 |
|
26199 | input.velocity = velocity;
|
26200 | input.velocityX = velocityX;
|
26201 | input.velocityY = velocityY;
|
26202 | input.direction = direction;
|
26203 | }
|
26204 | |
26205 |
|
26206 |
|
26207 |
|
26208 |
|
26209 |
|
26210 |
|
26211 | function simpleCloneInputData(input) {
|
26212 |
|
26213 |
|
26214 | var pointers = [];
|
26215 | var i = 0;
|
26216 |
|
26217 | while (i < input.pointers.length) {
|
26218 | pointers[i] = {
|
26219 | clientX: round(input.pointers[i].clientX),
|
26220 | clientY: round(input.pointers[i].clientY)
|
26221 | };
|
26222 | i++;
|
26223 | }
|
26224 |
|
26225 | return {
|
26226 | timeStamp: now(),
|
26227 | pointers: pointers,
|
26228 | center: getCenter(pointers),
|
26229 | deltaX: input.deltaX,
|
26230 | deltaY: input.deltaY
|
26231 | };
|
26232 | }
|
26233 | |
26234 |
|
26235 |
|
26236 |
|
26237 |
|
26238 |
|
26239 |
|
26240 | function getCenter(pointers) {
|
26241 | var pointersLength = pointers.length;
|
26242 |
|
26243 | if (pointersLength === 1) {
|
26244 | return {
|
26245 | x: round(pointers[0].clientX),
|
26246 | y: round(pointers[0].clientY)
|
26247 | };
|
26248 | }
|
26249 |
|
26250 | var x = 0,
|
26251 | y = 0,
|
26252 | i = 0;
|
26253 |
|
26254 | while (i < pointersLength) {
|
26255 | x += pointers[i].clientX;
|
26256 | y += pointers[i].clientY;
|
26257 | i++;
|
26258 | }
|
26259 |
|
26260 | return {
|
26261 | x: round(x / pointersLength),
|
26262 | y: round(y / pointersLength)
|
26263 | };
|
26264 | }
|
26265 | |
26266 |
|
26267 |
|
26268 |
|
26269 |
|
26270 |
|
26271 |
|
26272 |
|
26273 |
|
26274 | function getVelocity(deltaTime, x, y) {
|
26275 | return {
|
26276 | x: x / deltaTime || 0,
|
26277 | y: y / deltaTime || 0
|
26278 | };
|
26279 | }
|
26280 | |
26281 |
|
26282 |
|
26283 |
|
26284 |
|
26285 |
|
26286 |
|
26287 |
|
26288 | function getDirection(x, y) {
|
26289 | if (x === y) {
|
26290 | return DIRECTION_NONE;
|
26291 | }
|
26292 |
|
26293 | if (abs(x) >= abs(y)) {
|
26294 | return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
26295 | }
|
26296 |
|
26297 | return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
26298 | }
|
26299 | |
26300 |
|
26301 |
|
26302 |
|
26303 |
|
26304 |
|
26305 |
|
26306 |
|
26307 |
|
26308 | function getDistance(p1, p2, props) {
|
26309 | if (!props) {
|
26310 | props = PROPS_XY;
|
26311 | }
|
26312 |
|
26313 | var x = p2[props[0]] - p1[props[0]],
|
26314 | y = p2[props[1]] - p1[props[1]];
|
26315 | return Math.sqrt(x * x + y * y);
|
26316 | }
|
26317 | |
26318 |
|
26319 |
|
26320 |
|
26321 |
|
26322 |
|
26323 |
|
26324 |
|
26325 |
|
26326 | function getAngle(p1, p2, props) {
|
26327 | if (!props) {
|
26328 | props = PROPS_XY;
|
26329 | }
|
26330 |
|
26331 | var x = p2[props[0]] - p1[props[0]],
|
26332 | y = p2[props[1]] - p1[props[1]];
|
26333 | return Math.atan2(y, x) * 180 / Math.PI;
|
26334 | }
|
26335 | |
26336 |
|
26337 |
|
26338 |
|
26339 |
|
26340 |
|
26341 |
|
26342 |
|
26343 | function getRotation(start, end) {
|
26344 | return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
26345 | }
|
26346 | |
26347 |
|
26348 |
|
26349 |
|
26350 |
|
26351 |
|
26352 |
|
26353 |
|
26354 |
|
26355 | function getScale(start, end) {
|
26356 | return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
26357 | }
|
26358 |
|
26359 | var MOUSE_INPUT_MAP = {
|
26360 | mousedown: INPUT_START,
|
26361 | mousemove: INPUT_MOVE,
|
26362 | mouseup: INPUT_END
|
26363 | };
|
26364 | var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
26365 | var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
26366 | |
26367 |
|
26368 |
|
26369 |
|
26370 |
|
26371 |
|
26372 | function MouseInput() {
|
26373 | this.evEl = MOUSE_ELEMENT_EVENTS;
|
26374 | this.evWin = MOUSE_WINDOW_EVENTS;
|
26375 | this.pressed = false;
|
26376 |
|
26377 | Input.apply(this, arguments);
|
26378 | }
|
26379 |
|
26380 | inherit(MouseInput, Input, {
|
26381 | |
26382 |
|
26383 |
|
26384 |
|
26385 | handler: function MEhandler(ev) {
|
26386 | var eventType = MOUSE_INPUT_MAP[ev.type];
|
26387 |
|
26388 | if (eventType & INPUT_START && ev.button === 0) {
|
26389 | this.pressed = true;
|
26390 | }
|
26391 |
|
26392 | if (eventType & INPUT_MOVE && ev.which !== 1) {
|
26393 | eventType = INPUT_END;
|
26394 | }
|
26395 |
|
26396 |
|
26397 | if (!this.pressed) {
|
26398 | return;
|
26399 | }
|
26400 |
|
26401 | if (eventType & INPUT_END) {
|
26402 | this.pressed = false;
|
26403 | }
|
26404 |
|
26405 | this.callback(this.manager, eventType, {
|
26406 | pointers: [ev],
|
26407 | changedPointers: [ev],
|
26408 | pointerType: INPUT_TYPE_MOUSE,
|
26409 | srcEvent: ev
|
26410 | });
|
26411 | }
|
26412 | });
|
26413 | var POINTER_INPUT_MAP = {
|
26414 | pointerdown: INPUT_START,
|
26415 | pointermove: INPUT_MOVE,
|
26416 | pointerup: INPUT_END,
|
26417 | pointercancel: INPUT_CANCEL,
|
26418 | pointerout: INPUT_CANCEL
|
26419 | };
|
26420 |
|
26421 | var IE10_POINTER_TYPE_ENUM = {
|
26422 | 2: INPUT_TYPE_TOUCH,
|
26423 | 3: INPUT_TYPE_PEN,
|
26424 | 4: INPUT_TYPE_MOUSE,
|
26425 | 5: INPUT_TYPE_KINECT
|
26426 |
|
26427 | };
|
26428 | var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
26429 | var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
26430 |
|
26431 | if (window.MSPointerEvent && !window.PointerEvent) {
|
26432 | POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
26433 | POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
26434 | }
|
26435 | |
26436 |
|
26437 |
|
26438 |
|
26439 |
|
26440 |
|
26441 |
|
26442 | function PointerEventInput() {
|
26443 | this.evEl = POINTER_ELEMENT_EVENTS;
|
26444 | this.evWin = POINTER_WINDOW_EVENTS;
|
26445 | Input.apply(this, arguments);
|
26446 | this.store = this.manager.session.pointerEvents = [];
|
26447 | }
|
26448 |
|
26449 | inherit(PointerEventInput, Input, {
|
26450 | |
26451 |
|
26452 |
|
26453 |
|
26454 | handler: function PEhandler(ev) {
|
26455 | var store = this.store;
|
26456 | var removePointer = false;
|
26457 | var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
|
26458 | var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
26459 | var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
26460 | var isTouch = pointerType == INPUT_TYPE_TOUCH;
|
26461 |
|
26462 | var storeIndex = inArray(store, ev.pointerId, 'pointerId');
|
26463 |
|
26464 | if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
26465 | if (storeIndex < 0) {
|
26466 | store.push(ev);
|
26467 | storeIndex = store.length - 1;
|
26468 | }
|
26469 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
26470 | removePointer = true;
|
26471 | }
|
26472 |
|
26473 |
|
26474 | if (storeIndex < 0) {
|
26475 | return;
|
26476 | }
|
26477 |
|
26478 |
|
26479 | store[storeIndex] = ev;
|
26480 | this.callback(this.manager, eventType, {
|
26481 | pointers: store,
|
26482 | changedPointers: [ev],
|
26483 | pointerType: pointerType,
|
26484 | srcEvent: ev
|
26485 | });
|
26486 |
|
26487 | if (removePointer) {
|
26488 |
|
26489 | store.splice(storeIndex, 1);
|
26490 | }
|
26491 | }
|
26492 | });
|
26493 | var SINGLE_TOUCH_INPUT_MAP = {
|
26494 | touchstart: INPUT_START,
|
26495 | touchmove: INPUT_MOVE,
|
26496 | touchend: INPUT_END,
|
26497 | touchcancel: INPUT_CANCEL
|
26498 | };
|
26499 | var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
26500 | var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
26501 | |
26502 |
|
26503 |
|
26504 |
|
26505 |
|
26506 |
|
26507 | function SingleTouchInput() {
|
26508 | this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
26509 | this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
26510 | this.started = false;
|
26511 | Input.apply(this, arguments);
|
26512 | }
|
26513 |
|
26514 | inherit(SingleTouchInput, Input, {
|
26515 | handler: function TEhandler(ev) {
|
26516 | var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
26517 |
|
26518 | if (type === INPUT_START) {
|
26519 | this.started = true;
|
26520 | }
|
26521 |
|
26522 | if (!this.started) {
|
26523 | return;
|
26524 | }
|
26525 |
|
26526 | var touches = normalizeSingleTouches.call(this, ev, type);
|
26527 |
|
26528 | if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
26529 | this.started = false;
|
26530 | }
|
26531 |
|
26532 | this.callback(this.manager, type, {
|
26533 | pointers: touches[0],
|
26534 | changedPointers: touches[1],
|
26535 | pointerType: INPUT_TYPE_TOUCH,
|
26536 | srcEvent: ev
|
26537 | });
|
26538 | }
|
26539 | });
|
26540 | |
26541 |
|
26542 |
|
26543 |
|
26544 |
|
26545 |
|
26546 |
|
26547 | function normalizeSingleTouches(ev, type) {
|
26548 | var all = toArray(ev.touches);
|
26549 | var changed = toArray(ev.changedTouches);
|
26550 |
|
26551 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
26552 | all = uniqueArray(all.concat(changed), 'identifier', true);
|
26553 | }
|
26554 |
|
26555 | return [all, changed];
|
26556 | }
|
26557 |
|
26558 | var TOUCH_INPUT_MAP = {
|
26559 | touchstart: INPUT_START,
|
26560 | touchmove: INPUT_MOVE,
|
26561 | touchend: INPUT_END,
|
26562 | touchcancel: INPUT_CANCEL
|
26563 | };
|
26564 | var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
26565 | |
26566 |
|
26567 |
|
26568 |
|
26569 |
|
26570 |
|
26571 | function TouchInput() {
|
26572 | this.evTarget = TOUCH_TARGET_EVENTS;
|
26573 | this.targetIds = {};
|
26574 | Input.apply(this, arguments);
|
26575 | }
|
26576 |
|
26577 | inherit(TouchInput, Input, {
|
26578 | handler: function MTEhandler(ev) {
|
26579 | var type = TOUCH_INPUT_MAP[ev.type];
|
26580 | var touches = getTouches.call(this, ev, type);
|
26581 |
|
26582 | if (!touches) {
|
26583 | return;
|
26584 | }
|
26585 |
|
26586 | this.callback(this.manager, type, {
|
26587 | pointers: touches[0],
|
26588 | changedPointers: touches[1],
|
26589 | pointerType: INPUT_TYPE_TOUCH,
|
26590 | srcEvent: ev
|
26591 | });
|
26592 | }
|
26593 | });
|
26594 | |
26595 |
|
26596 |
|
26597 |
|
26598 |
|
26599 |
|
26600 |
|
26601 | function getTouches(ev, type) {
|
26602 | var allTouches = toArray(ev.touches);
|
26603 | var targetIds = this.targetIds;
|
26604 |
|
26605 | if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
26606 | targetIds[allTouches[0].identifier] = true;
|
26607 | return [allTouches, allTouches];
|
26608 | }
|
26609 |
|
26610 | var i,
|
26611 | targetTouches,
|
26612 | changedTouches = toArray(ev.changedTouches),
|
26613 | changedTargetTouches = [],
|
26614 | target = this.target;
|
26615 |
|
26616 | targetTouches = allTouches.filter(function (touch) {
|
26617 | return hasParent(touch.target, target);
|
26618 | });
|
26619 |
|
26620 | if (type === INPUT_START) {
|
26621 | i = 0;
|
26622 |
|
26623 | while (i < targetTouches.length) {
|
26624 | targetIds[targetTouches[i].identifier] = true;
|
26625 | i++;
|
26626 | }
|
26627 | }
|
26628 |
|
26629 |
|
26630 | i = 0;
|
26631 |
|
26632 | while (i < changedTouches.length) {
|
26633 | if (targetIds[changedTouches[i].identifier]) {
|
26634 | changedTargetTouches.push(changedTouches[i]);
|
26635 | }
|
26636 |
|
26637 |
|
26638 | if (type & (INPUT_END | INPUT_CANCEL)) {
|
26639 | delete targetIds[changedTouches[i].identifier];
|
26640 | }
|
26641 |
|
26642 | i++;
|
26643 | }
|
26644 |
|
26645 | if (!changedTargetTouches.length) {
|
26646 | return;
|
26647 | }
|
26648 |
|
26649 | return [
|
26650 | uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), changedTargetTouches];
|
26651 | }
|
26652 | |
26653 |
|
26654 |
|
26655 |
|
26656 |
|
26657 |
|
26658 |
|
26659 |
|
26660 |
|
26661 |
|
26662 |
|
26663 | var DEDUP_TIMEOUT = 2500;
|
26664 | var DEDUP_DISTANCE = 25;
|
26665 |
|
26666 | function TouchMouseInput() {
|
26667 | Input.apply(this, arguments);
|
26668 | var handler = bindFn(this.handler, this);
|
26669 | this.touch = new TouchInput(this.manager, handler);
|
26670 | this.mouse = new MouseInput(this.manager, handler);
|
26671 | this.primaryTouch = null;
|
26672 | this.lastTouches = [];
|
26673 | }
|
26674 |
|
26675 | inherit(TouchMouseInput, Input, {
|
26676 | |
26677 |
|
26678 |
|
26679 |
|
26680 |
|
26681 |
|
26682 | handler: function TMEhandler(manager, inputEvent, inputData) {
|
26683 | var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH,
|
26684 | isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
|
26685 |
|
26686 | if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
26687 | return;
|
26688 | }
|
26689 |
|
26690 |
|
26691 | if (isTouch) {
|
26692 | recordTouches.call(this, inputEvent, inputData);
|
26693 | } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
26694 | return;
|
26695 | }
|
26696 |
|
26697 | this.callback(manager, inputEvent, inputData);
|
26698 | },
|
26699 |
|
26700 | |
26701 |
|
26702 |
|
26703 | destroy: function destroy() {
|
26704 | this.touch.destroy();
|
26705 | this.mouse.destroy();
|
26706 | }
|
26707 | });
|
26708 |
|
26709 | function recordTouches(eventType, eventData) {
|
26710 | if (eventType & INPUT_START) {
|
26711 | this.primaryTouch = eventData.changedPointers[0].identifier;
|
26712 | setLastTouch.call(this, eventData);
|
26713 | } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
26714 | setLastTouch.call(this, eventData);
|
26715 | }
|
26716 | }
|
26717 |
|
26718 | function setLastTouch(eventData) {
|
26719 | var touch = eventData.changedPointers[0];
|
26720 |
|
26721 | if (touch.identifier === this.primaryTouch) {
|
26722 | var lastTouch = {
|
26723 | x: touch.clientX,
|
26724 | y: touch.clientY
|
26725 | };
|
26726 | this.lastTouches.push(lastTouch);
|
26727 | var lts = this.lastTouches;
|
26728 |
|
26729 | var removeLastTouch = function () {
|
26730 | var i = lts.indexOf(lastTouch);
|
26731 |
|
26732 | if (i > -1) {
|
26733 | lts.splice(i, 1);
|
26734 | }
|
26735 | };
|
26736 |
|
26737 | setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
26738 | }
|
26739 | }
|
26740 |
|
26741 | function isSyntheticEvent(eventData) {
|
26742 | var x = eventData.srcEvent.clientX,
|
26743 | y = eventData.srcEvent.clientY;
|
26744 |
|
26745 | for (var i = 0; i < this.lastTouches.length; i++) {
|
26746 | var t = this.lastTouches[i];
|
26747 | var dx = Math.abs(x - t.x),
|
26748 | dy = Math.abs(y - t.y);
|
26749 |
|
26750 | if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
26751 | return true;
|
26752 | }
|
26753 | }
|
26754 |
|
26755 | return false;
|
26756 | }
|
26757 |
|
26758 | var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
26759 | var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
|
26760 |
|
26761 | var TOUCH_ACTION_COMPUTE = 'compute';
|
26762 | var TOUCH_ACTION_AUTO = 'auto';
|
26763 | var TOUCH_ACTION_MANIPULATION = 'manipulation';
|
26764 |
|
26765 | var TOUCH_ACTION_NONE = 'none';
|
26766 | var TOUCH_ACTION_PAN_X = 'pan-x';
|
26767 | var TOUCH_ACTION_PAN_Y = 'pan-y';
|
26768 | var TOUCH_ACTION_MAP = getTouchActionProps();
|
26769 | |
26770 |
|
26771 |
|
26772 |
|
26773 |
|
26774 |
|
26775 |
|
26776 |
|
26777 | function TouchAction(manager, value) {
|
26778 | this.manager = manager;
|
26779 | this.set(value);
|
26780 | }
|
26781 |
|
26782 | TouchAction.prototype = {
|
26783 | |
26784 |
|
26785 |
|
26786 |
|
26787 | set: function (value) {
|
26788 |
|
26789 | if (value == TOUCH_ACTION_COMPUTE) {
|
26790 | value = this.compute();
|
26791 | }
|
26792 |
|
26793 | if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
26794 | this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
26795 | }
|
26796 |
|
26797 | this.actions = value.toLowerCase().trim();
|
26798 | },
|
26799 |
|
26800 | |
26801 |
|
26802 |
|
26803 | update: function () {
|
26804 | this.set(this.manager.options.touchAction);
|
26805 | },
|
26806 |
|
26807 | |
26808 |
|
26809 |
|
26810 |
|
26811 | compute: function () {
|
26812 | var actions = [];
|
26813 | each(this.manager.recognizers, function (recognizer) {
|
26814 | if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
26815 | actions = actions.concat(recognizer.getTouchAction());
|
26816 | }
|
26817 | });
|
26818 | return cleanTouchActions(actions.join(' '));
|
26819 | },
|
26820 |
|
26821 | |
26822 |
|
26823 |
|
26824 |
|
26825 | preventDefaults: function (input) {
|
26826 | var srcEvent = input.srcEvent;
|
26827 | var direction = input.offsetDirection;
|
26828 |
|
26829 | if (this.manager.session.prevented) {
|
26830 | srcEvent.preventDefault();
|
26831 | return;
|
26832 | }
|
26833 |
|
26834 | var actions = this.actions;
|
26835 | var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
26836 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
26837 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
26838 |
|
26839 | if (hasNone) {
|
26840 |
|
26841 | var isTapPointer = input.pointers.length === 1;
|
26842 | var isTapMovement = input.distance < 2;
|
26843 | var isTapTouchTime = input.deltaTime < 250;
|
26844 |
|
26845 | if (isTapPointer && isTapMovement && isTapTouchTime) {
|
26846 | return;
|
26847 | }
|
26848 | }
|
26849 |
|
26850 | if (hasPanX && hasPanY) {
|
26851 |
|
26852 | return;
|
26853 | }
|
26854 |
|
26855 | if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
|
26856 | return this.preventSrc(srcEvent);
|
26857 | }
|
26858 | },
|
26859 |
|
26860 | |
26861 |
|
26862 |
|
26863 |
|
26864 | preventSrc: function (srcEvent) {
|
26865 | this.manager.session.prevented = true;
|
26866 | srcEvent.preventDefault();
|
26867 | }
|
26868 | };
|
26869 | |
26870 |
|
26871 |
|
26872 |
|
26873 |
|
26874 |
|
26875 | function cleanTouchActions(actions) {
|
26876 |
|
26877 | if (inStr(actions, TOUCH_ACTION_NONE)) {
|
26878 | return TOUCH_ACTION_NONE;
|
26879 | }
|
26880 |
|
26881 | var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
|
26882 | var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
|
26883 |
|
26884 |
|
26885 |
|
26886 |
|
26887 | if (hasPanX && hasPanY) {
|
26888 | return TOUCH_ACTION_NONE;
|
26889 | }
|
26890 |
|
26891 |
|
26892 | if (hasPanX || hasPanY) {
|
26893 | return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
26894 | }
|
26895 |
|
26896 |
|
26897 | if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
|
26898 | return TOUCH_ACTION_MANIPULATION;
|
26899 | }
|
26900 |
|
26901 | return TOUCH_ACTION_AUTO;
|
26902 | }
|
26903 |
|
26904 | function getTouchActionProps() {
|
26905 | if (!NATIVE_TOUCH_ACTION) {
|
26906 | return false;
|
26907 | }
|
26908 |
|
26909 | var touchMap = {};
|
26910 | var cssSupports = window.CSS && window.CSS.supports;
|
26911 | ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function (val) {
|
26912 |
|
26913 |
|
26914 | touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
26915 | });
|
26916 | return touchMap;
|
26917 | }
|
26918 | |
26919 |
|
26920 |
|
26921 |
|
26922 |
|
26923 |
|
26924 |
|
26925 |
|
26926 |
|
26927 |
|
26928 |
|
26929 |
|
26930 |
|
26931 |
|
26932 |
|
26933 |
|
26934 |
|
26935 |
|
26936 |
|
26937 |
|
26938 |
|
26939 |
|
26940 |
|
26941 |
|
26942 |
|
26943 |
|
26944 |
|
26945 |
|
26946 |
|
26947 | var STATE_POSSIBLE = 1;
|
26948 | var STATE_BEGAN = 2;
|
26949 | var STATE_CHANGED = 4;
|
26950 | var STATE_ENDED = 8;
|
26951 | var STATE_RECOGNIZED = STATE_ENDED;
|
26952 | var STATE_CANCELLED = 16;
|
26953 | var STATE_FAILED = 32;
|
26954 | |
26955 |
|
26956 |
|
26957 |
|
26958 |
|
26959 |
|
26960 |
|
26961 | function Recognizer(options) {
|
26962 | this.options = assign({}, this.defaults, options || {});
|
26963 | this.id = uniqueId();
|
26964 | this.manager = null;
|
26965 |
|
26966 | this.options.enable = ifUndefined(this.options.enable, true);
|
26967 | this.state = STATE_POSSIBLE;
|
26968 | this.simultaneous = {};
|
26969 | this.requireFail = [];
|
26970 | }
|
26971 |
|
26972 | Recognizer.prototype = {
|
26973 | |
26974 |
|
26975 |
|
26976 |
|
26977 | defaults: {},
|
26978 |
|
26979 | |
26980 |
|
26981 |
|
26982 |
|
26983 |
|
26984 | set: function (options) {
|
26985 | assign(this.options, options);
|
26986 |
|
26987 | this.manager && this.manager.touchAction.update();
|
26988 | return this;
|
26989 | },
|
26990 |
|
26991 | |
26992 |
|
26993 |
|
26994 |
|
26995 |
|
26996 | recognizeWith: function (otherRecognizer) {
|
26997 | if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
|
26998 | return this;
|
26999 | }
|
27000 |
|
27001 | var simultaneous = this.simultaneous;
|
27002 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
27003 |
|
27004 | if (!simultaneous[otherRecognizer.id]) {
|
27005 | simultaneous[otherRecognizer.id] = otherRecognizer;
|
27006 | otherRecognizer.recognizeWith(this);
|
27007 | }
|
27008 |
|
27009 | return this;
|
27010 | },
|
27011 |
|
27012 | |
27013 |
|
27014 |
|
27015 |
|
27016 |
|
27017 | dropRecognizeWith: function (otherRecognizer) {
|
27018 | if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
|
27019 | return this;
|
27020 | }
|
27021 |
|
27022 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
27023 | delete this.simultaneous[otherRecognizer.id];
|
27024 | return this;
|
27025 | },
|
27026 |
|
27027 | |
27028 |
|
27029 |
|
27030 |
|
27031 |
|
27032 | requireFailure: function (otherRecognizer) {
|
27033 | if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
|
27034 | return this;
|
27035 | }
|
27036 |
|
27037 | var requireFail = this.requireFail;
|
27038 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
27039 |
|
27040 | if (inArray(requireFail, otherRecognizer) === -1) {
|
27041 | requireFail.push(otherRecognizer);
|
27042 | otherRecognizer.requireFailure(this);
|
27043 | }
|
27044 |
|
27045 | return this;
|
27046 | },
|
27047 |
|
27048 | |
27049 |
|
27050 |
|
27051 |
|
27052 |
|
27053 | dropRequireFailure: function (otherRecognizer) {
|
27054 | if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
|
27055 | return this;
|
27056 | }
|
27057 |
|
27058 | otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
27059 | var index = inArray(this.requireFail, otherRecognizer);
|
27060 |
|
27061 | if (index > -1) {
|
27062 | this.requireFail.splice(index, 1);
|
27063 | }
|
27064 |
|
27065 | return this;
|
27066 | },
|
27067 |
|
27068 | |
27069 |
|
27070 |
|
27071 |
|
27072 | hasRequireFailures: function () {
|
27073 | return this.requireFail.length > 0;
|
27074 | },
|
27075 |
|
27076 | |
27077 |
|
27078 |
|
27079 |
|
27080 |
|
27081 | canRecognizeWith: function (otherRecognizer) {
|
27082 | return !!this.simultaneous[otherRecognizer.id];
|
27083 | },
|
27084 |
|
27085 | |
27086 |
|
27087 |
|
27088 |
|
27089 |
|
27090 | emit: function (input) {
|
27091 | var self = this;
|
27092 | var state = this.state;
|
27093 |
|
27094 | function emit(event) {
|
27095 | self.manager.emit(event, input);
|
27096 | }
|
27097 |
|
27098 |
|
27099 | if (state < STATE_ENDED) {
|
27100 | emit(self.options.event + stateStr(state));
|
27101 | }
|
27102 |
|
27103 | emit(self.options.event);
|
27104 |
|
27105 | if (input.additionalEvent) {
|
27106 |
|
27107 | emit(input.additionalEvent);
|
27108 | }
|
27109 |
|
27110 |
|
27111 | if (state >= STATE_ENDED) {
|
27112 | emit(self.options.event + stateStr(state));
|
27113 | }
|
27114 | },
|
27115 |
|
27116 | |
27117 |
|
27118 |
|
27119 |
|
27120 |
|
27121 |
|
27122 | tryEmit: function (input) {
|
27123 | if (this.canEmit()) {
|
27124 | return this.emit(input);
|
27125 | }
|
27126 |
|
27127 |
|
27128 | this.state = STATE_FAILED;
|
27129 | },
|
27130 |
|
27131 | |
27132 |
|
27133 |
|
27134 |
|
27135 | canEmit: function () {
|
27136 | var i = 0;
|
27137 |
|
27138 | while (i < this.requireFail.length) {
|
27139 | if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
27140 | return false;
|
27141 | }
|
27142 |
|
27143 | i++;
|
27144 | }
|
27145 |
|
27146 | return true;
|
27147 | },
|
27148 |
|
27149 | |
27150 |
|
27151 |
|
27152 |
|
27153 | recognize: function (inputData) {
|
27154 |
|
27155 |
|
27156 | var inputDataClone = assign({}, inputData);
|
27157 |
|
27158 | if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
27159 | this.reset();
|
27160 | this.state = STATE_FAILED;
|
27161 | return;
|
27162 | }
|
27163 |
|
27164 |
|
27165 | if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
27166 | this.state = STATE_POSSIBLE;
|
27167 | }
|
27168 |
|
27169 | this.state = this.process(inputDataClone);
|
27170 |
|
27171 |
|
27172 | if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
27173 | this.tryEmit(inputDataClone);
|
27174 | }
|
27175 | },
|
27176 |
|
27177 | |
27178 |
|
27179 |
|
27180 |
|
27181 |
|
27182 |
|
27183 |
|
27184 | process: function (inputData) {},
|
27185 |
|
27186 |
|
27187 | |
27188 |
|
27189 |
|
27190 |
|
27191 |
|
27192 | getTouchAction: function () {},
|
27193 |
|
27194 | |
27195 |
|
27196 |
|
27197 |
|
27198 |
|
27199 | reset: function () {}
|
27200 | };
|
27201 | |
27202 |
|
27203 |
|
27204 |
|
27205 |
|
27206 |
|
27207 | function stateStr(state) {
|
27208 | if (state & STATE_CANCELLED) {
|
27209 | return 'cancel';
|
27210 | } else if (state & STATE_ENDED) {
|
27211 | return 'end';
|
27212 | } else if (state & STATE_CHANGED) {
|
27213 | return 'move';
|
27214 | } else if (state & STATE_BEGAN) {
|
27215 | return 'start';
|
27216 | }
|
27217 |
|
27218 | return '';
|
27219 | }
|
27220 | |
27221 |
|
27222 |
|
27223 |
|
27224 |
|
27225 |
|
27226 |
|
27227 | function directionStr(direction) {
|
27228 | if (direction == DIRECTION_DOWN) {
|
27229 | return 'down';
|
27230 | } else if (direction == DIRECTION_UP) {
|
27231 | return 'up';
|
27232 | } else if (direction == DIRECTION_LEFT) {
|
27233 | return 'left';
|
27234 | } else if (direction == DIRECTION_RIGHT) {
|
27235 | return 'right';
|
27236 | }
|
27237 |
|
27238 | return '';
|
27239 | }
|
27240 | |
27241 |
|
27242 |
|
27243 |
|
27244 |
|
27245 |
|
27246 |
|
27247 |
|
27248 | function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
27249 | var manager = recognizer.manager;
|
27250 |
|
27251 | if (manager) {
|
27252 | return manager.get(otherRecognizer);
|
27253 | }
|
27254 |
|
27255 | return otherRecognizer;
|
27256 | }
|
27257 | |
27258 |
|
27259 |
|
27260 |
|
27261 |
|
27262 |
|
27263 |
|
27264 | function AttrRecognizer() {
|
27265 | Recognizer.apply(this, arguments);
|
27266 | }
|
27267 |
|
27268 | inherit(AttrRecognizer, Recognizer, {
|
27269 | |
27270 |
|
27271 |
|
27272 |
|
27273 | defaults: {
|
27274 | |
27275 |
|
27276 |
|
27277 |
|
27278 | pointers: 1
|
27279 | },
|
27280 |
|
27281 | |
27282 |
|
27283 |
|
27284 |
|
27285 |
|
27286 |
|
27287 | attrTest: function (input) {
|
27288 | var optionPointers = this.options.pointers;
|
27289 | return optionPointers === 0 || input.pointers.length === optionPointers;
|
27290 | },
|
27291 |
|
27292 | |
27293 |
|
27294 |
|
27295 |
|
27296 |
|
27297 |
|
27298 | process: function (input) {
|
27299 | var state = this.state;
|
27300 | var eventType = input.eventType;
|
27301 | var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
27302 | var isValid = this.attrTest(input);
|
27303 |
|
27304 | if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
27305 | return state | STATE_CANCELLED;
|
27306 | } else if (isRecognized || isValid) {
|
27307 | if (eventType & INPUT_END) {
|
27308 | return state | STATE_ENDED;
|
27309 | } else if (!(state & STATE_BEGAN)) {
|
27310 | return STATE_BEGAN;
|
27311 | }
|
27312 |
|
27313 | return state | STATE_CHANGED;
|
27314 | }
|
27315 |
|
27316 | return STATE_FAILED;
|
27317 | }
|
27318 | });
|
27319 | |
27320 |
|
27321 |
|
27322 |
|
27323 |
|
27324 |
|
27325 |
|
27326 | function PanRecognizer() {
|
27327 | AttrRecognizer.apply(this, arguments);
|
27328 | this.pX = null;
|
27329 | this.pY = null;
|
27330 | }
|
27331 |
|
27332 | inherit(PanRecognizer, AttrRecognizer, {
|
27333 | |
27334 |
|
27335 |
|
27336 |
|
27337 | defaults: {
|
27338 | event: 'pan',
|
27339 | threshold: 10,
|
27340 | pointers: 1,
|
27341 | direction: DIRECTION_ALL
|
27342 | },
|
27343 | getTouchAction: function () {
|
27344 | var direction = this.options.direction;
|
27345 | var actions = [];
|
27346 |
|
27347 | if (direction & DIRECTION_HORIZONTAL) {
|
27348 | actions.push(TOUCH_ACTION_PAN_Y);
|
27349 | }
|
27350 |
|
27351 | if (direction & DIRECTION_VERTICAL) {
|
27352 | actions.push(TOUCH_ACTION_PAN_X);
|
27353 | }
|
27354 |
|
27355 | return actions;
|
27356 | },
|
27357 | directionTest: function (input) {
|
27358 | var options = this.options;
|
27359 | var hasMoved = true;
|
27360 | var distance = input.distance;
|
27361 | var direction = input.direction;
|
27362 | var x = input.deltaX;
|
27363 | var y = input.deltaY;
|
27364 |
|
27365 | if (!(direction & options.direction)) {
|
27366 | if (options.direction & DIRECTION_HORIZONTAL) {
|
27367 | direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
27368 | hasMoved = x != this.pX;
|
27369 | distance = Math.abs(input.deltaX);
|
27370 | } else {
|
27371 | direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
27372 | hasMoved = y != this.pY;
|
27373 | distance = Math.abs(input.deltaY);
|
27374 | }
|
27375 | }
|
27376 |
|
27377 | input.direction = direction;
|
27378 | return hasMoved && distance > options.threshold && direction & options.direction;
|
27379 | },
|
27380 | attrTest: function (input) {
|
27381 | return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
|
27382 | },
|
27383 | emit: function (input) {
|
27384 | this.pX = input.deltaX;
|
27385 | this.pY = input.deltaY;
|
27386 | var direction = directionStr(input.direction);
|
27387 |
|
27388 | if (direction) {
|
27389 | input.additionalEvent = this.options.event + direction;
|
27390 | }
|
27391 |
|
27392 | this._super.emit.call(this, input);
|
27393 | }
|
27394 | });
|
27395 | |
27396 |
|
27397 |
|
27398 |
|
27399 |
|
27400 |
|
27401 |
|
27402 | function PinchRecognizer() {
|
27403 | AttrRecognizer.apply(this, arguments);
|
27404 | }
|
27405 |
|
27406 | inherit(PinchRecognizer, AttrRecognizer, {
|
27407 | |
27408 |
|
27409 |
|
27410 |
|
27411 | defaults: {
|
27412 | event: 'pinch',
|
27413 | threshold: 0,
|
27414 | pointers: 2
|
27415 | },
|
27416 | getTouchAction: function () {
|
27417 | return [TOUCH_ACTION_NONE];
|
27418 | },
|
27419 | attrTest: function (input) {
|
27420 | return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
27421 | },
|
27422 | emit: function (input) {
|
27423 | if (input.scale !== 1) {
|
27424 | var inOut = input.scale < 1 ? 'in' : 'out';
|
27425 | input.additionalEvent = this.options.event + inOut;
|
27426 | }
|
27427 |
|
27428 | this._super.emit.call(this, input);
|
27429 | }
|
27430 | });
|
27431 | |
27432 |
|
27433 |
|
27434 |
|
27435 |
|
27436 |
|
27437 |
|
27438 | function PressRecognizer() {
|
27439 | Recognizer.apply(this, arguments);
|
27440 | this._timer = null;
|
27441 | this._input = null;
|
27442 | }
|
27443 |
|
27444 | inherit(PressRecognizer, Recognizer, {
|
27445 | |
27446 |
|
27447 |
|
27448 |
|
27449 | defaults: {
|
27450 | event: 'press',
|
27451 | pointers: 1,
|
27452 | time: 251,
|
27453 |
|
27454 | threshold: 9
|
27455 |
|
27456 | },
|
27457 | getTouchAction: function () {
|
27458 | return [TOUCH_ACTION_AUTO];
|
27459 | },
|
27460 | process: function (input) {
|
27461 | var options = this.options;
|
27462 | var validPointers = input.pointers.length === options.pointers;
|
27463 | var validMovement = input.distance < options.threshold;
|
27464 | var validTime = input.deltaTime > options.time;
|
27465 | this._input = input;
|
27466 |
|
27467 |
|
27468 | if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
|
27469 | this.reset();
|
27470 | } else if (input.eventType & INPUT_START) {
|
27471 | this.reset();
|
27472 | this._timer = setTimeoutContext(function () {
|
27473 | this.state = STATE_RECOGNIZED;
|
27474 | this.tryEmit();
|
27475 | }, options.time, this);
|
27476 | } else if (input.eventType & INPUT_END) {
|
27477 | return STATE_RECOGNIZED;
|
27478 | }
|
27479 |
|
27480 | return STATE_FAILED;
|
27481 | },
|
27482 | reset: function () {
|
27483 | clearTimeout(this._timer);
|
27484 | },
|
27485 | emit: function (input) {
|
27486 | if (this.state !== STATE_RECOGNIZED) {
|
27487 | return;
|
27488 | }
|
27489 |
|
27490 | if (input && input.eventType & INPUT_END) {
|
27491 | this.manager.emit(this.options.event + 'up', input);
|
27492 | } else {
|
27493 | this._input.timeStamp = now();
|
27494 | this.manager.emit(this.options.event, this._input);
|
27495 | }
|
27496 | }
|
27497 | });
|
27498 | |
27499 |
|
27500 |
|
27501 |
|
27502 |
|
27503 |
|
27504 |
|
27505 | function RotateRecognizer() {
|
27506 | AttrRecognizer.apply(this, arguments);
|
27507 | }
|
27508 |
|
27509 | inherit(RotateRecognizer, AttrRecognizer, {
|
27510 | |
27511 |
|
27512 |
|
27513 |
|
27514 | defaults: {
|
27515 | event: 'rotate',
|
27516 | threshold: 0,
|
27517 | pointers: 2
|
27518 | },
|
27519 | getTouchAction: function () {
|
27520 | return [TOUCH_ACTION_NONE];
|
27521 | },
|
27522 | attrTest: function (input) {
|
27523 | return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
27524 | }
|
27525 | });
|
27526 | |
27527 |
|
27528 |
|
27529 |
|
27530 |
|
27531 |
|
27532 |
|
27533 | function SwipeRecognizer() {
|
27534 | AttrRecognizer.apply(this, arguments);
|
27535 | }
|
27536 |
|
27537 | inherit(SwipeRecognizer, AttrRecognizer, {
|
27538 | |
27539 |
|
27540 |
|
27541 |
|
27542 | defaults: {
|
27543 | event: 'swipe',
|
27544 | threshold: 10,
|
27545 | velocity: 0.3,
|
27546 | direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
27547 | pointers: 1
|
27548 | },
|
27549 | getTouchAction: function () {
|
27550 | return PanRecognizer.prototype.getTouchAction.call(this);
|
27551 | },
|
27552 | attrTest: function (input) {
|
27553 | var direction = this.options.direction;
|
27554 | var velocity;
|
27555 |
|
27556 | if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
27557 | velocity = input.overallVelocity;
|
27558 | } else if (direction & DIRECTION_HORIZONTAL) {
|
27559 | velocity = input.overallVelocityX;
|
27560 | } else if (direction & DIRECTION_VERTICAL) {
|
27561 | velocity = input.overallVelocityY;
|
27562 | }
|
27563 |
|
27564 | return this._super.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;
|
27565 | },
|
27566 | emit: function (input) {
|
27567 | var direction = directionStr(input.offsetDirection);
|
27568 |
|
27569 | if (direction) {
|
27570 | this.manager.emit(this.options.event + direction, input);
|
27571 | }
|
27572 |
|
27573 | this.manager.emit(this.options.event, input);
|
27574 | }
|
27575 | });
|
27576 | |
27577 |
|
27578 |
|
27579 |
|
27580 |
|
27581 |
|
27582 |
|
27583 |
|
27584 |
|
27585 |
|
27586 |
|
27587 | function TapRecognizer() {
|
27588 | Recognizer.apply(this, arguments);
|
27589 |
|
27590 |
|
27591 | this.pTime = false;
|
27592 | this.pCenter = false;
|
27593 | this._timer = null;
|
27594 | this._input = null;
|
27595 | this.count = 0;
|
27596 | }
|
27597 |
|
27598 | inherit(TapRecognizer, Recognizer, {
|
27599 | |
27600 |
|
27601 |
|
27602 |
|
27603 | defaults: {
|
27604 | event: 'tap',
|
27605 | pointers: 1,
|
27606 | taps: 1,
|
27607 | interval: 300,
|
27608 |
|
27609 | time: 250,
|
27610 |
|
27611 | threshold: 9,
|
27612 |
|
27613 | posThreshold: 10
|
27614 |
|
27615 | },
|
27616 | getTouchAction: function () {
|
27617 | return [TOUCH_ACTION_MANIPULATION];
|
27618 | },
|
27619 | process: function (input) {
|
27620 | var options = this.options;
|
27621 | var validPointers = input.pointers.length === options.pointers;
|
27622 | var validMovement = input.distance < options.threshold;
|
27623 | var validTouchTime = input.deltaTime < options.time;
|
27624 | this.reset();
|
27625 |
|
27626 | if (input.eventType & INPUT_START && this.count === 0) {
|
27627 | return this.failTimeout();
|
27628 | }
|
27629 |
|
27630 |
|
27631 |
|
27632 | if (validMovement && validTouchTime && validPointers) {
|
27633 | if (input.eventType != INPUT_END) {
|
27634 | return this.failTimeout();
|
27635 | }
|
27636 |
|
27637 | var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
|
27638 | var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
27639 | this.pTime = input.timeStamp;
|
27640 | this.pCenter = input.center;
|
27641 |
|
27642 | if (!validMultiTap || !validInterval) {
|
27643 | this.count = 1;
|
27644 | } else {
|
27645 | this.count += 1;
|
27646 | }
|
27647 |
|
27648 | this._input = input;
|
27649 |
|
27650 |
|
27651 | var tapCount = this.count % options.taps;
|
27652 |
|
27653 | if (tapCount === 0) {
|
27654 |
|
27655 |
|
27656 | if (!this.hasRequireFailures()) {
|
27657 | return STATE_RECOGNIZED;
|
27658 | } else {
|
27659 | this._timer = setTimeoutContext(function () {
|
27660 | this.state = STATE_RECOGNIZED;
|
27661 | this.tryEmit();
|
27662 | }, options.interval, this);
|
27663 | return STATE_BEGAN;
|
27664 | }
|
27665 | }
|
27666 | }
|
27667 |
|
27668 | return STATE_FAILED;
|
27669 | },
|
27670 | failTimeout: function () {
|
27671 | this._timer = setTimeoutContext(function () {
|
27672 | this.state = STATE_FAILED;
|
27673 | }, this.options.interval, this);
|
27674 | return STATE_FAILED;
|
27675 | },
|
27676 | reset: function () {
|
27677 | clearTimeout(this._timer);
|
27678 | },
|
27679 | emit: function () {
|
27680 | if (this.state == STATE_RECOGNIZED) {
|
27681 | this._input.tapCount = this.count;
|
27682 | this.manager.emit(this.options.event, this._input);
|
27683 | }
|
27684 | }
|
27685 | });
|
27686 | |
27687 |
|
27688 |
|
27689 |
|
27690 |
|
27691 |
|
27692 |
|
27693 | function Hammer(element, options) {
|
27694 | options = options || {};
|
27695 | options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
|
27696 | return new Manager(element, options);
|
27697 | }
|
27698 | |
27699 |
|
27700 |
|
27701 |
|
27702 |
|
27703 | Hammer.VERSION = '2.0.7';
|
27704 | |
27705 |
|
27706 |
|
27707 |
|
27708 |
|
27709 | Hammer.defaults = {
|
27710 | |
27711 |
|
27712 |
|
27713 |
|
27714 |
|
27715 |
|
27716 | domEvents: false,
|
27717 |
|
27718 | |
27719 |
|
27720 |
|
27721 |
|
27722 |
|
27723 |
|
27724 | touchAction: TOUCH_ACTION_COMPUTE,
|
27725 |
|
27726 | |
27727 |
|
27728 |
|
27729 |
|
27730 | enable: true,
|
27731 |
|
27732 | |
27733 |
|
27734 |
|
27735 |
|
27736 |
|
27737 |
|
27738 |
|
27739 | inputTarget: null,
|
27740 |
|
27741 | |
27742 |
|
27743 |
|
27744 |
|
27745 |
|
27746 | inputClass: null,
|
27747 |
|
27748 | |
27749 |
|
27750 |
|
27751 |
|
27752 |
|
27753 | preset: [
|
27754 | [RotateRecognizer, {
|
27755 | enable: false
|
27756 | }], [PinchRecognizer, {
|
27757 | enable: false
|
27758 | }, ['rotate']], [SwipeRecognizer, {
|
27759 | direction: DIRECTION_HORIZONTAL
|
27760 | }], [PanRecognizer, {
|
27761 | direction: DIRECTION_HORIZONTAL
|
27762 | }, ['swipe']], [TapRecognizer], [TapRecognizer, {
|
27763 | event: 'doubletap',
|
27764 | taps: 2
|
27765 | }, ['tap']], [PressRecognizer]],
|
27766 |
|
27767 | |
27768 |
|
27769 |
|
27770 |
|
27771 |
|
27772 | cssProps: {
|
27773 | |
27774 |
|
27775 |
|
27776 |
|
27777 |
|
27778 | userSelect: 'none',
|
27779 |
|
27780 | |
27781 |
|
27782 |
|
27783 |
|
27784 |
|
27785 | touchSelect: 'none',
|
27786 |
|
27787 | |
27788 |
|
27789 |
|
27790 |
|
27791 |
|
27792 |
|
27793 |
|
27794 | touchCallout: 'none',
|
27795 |
|
27796 | |
27797 |
|
27798 |
|
27799 |
|
27800 |
|
27801 | contentZooming: 'none',
|
27802 |
|
27803 | |
27804 |
|
27805 |
|
27806 |
|
27807 |
|
27808 | userDrag: 'none',
|
27809 |
|
27810 | |
27811 |
|
27812 |
|
27813 |
|
27814 |
|
27815 |
|
27816 | tapHighlightColor: 'rgba(0,0,0,0)'
|
27817 | }
|
27818 | };
|
27819 | var STOP = 1;
|
27820 | var FORCED_STOP = 2;
|
27821 | |
27822 |
|
27823 |
|
27824 |
|
27825 |
|
27826 |
|
27827 |
|
27828 | function Manager(element, options) {
|
27829 | this.options = assign({}, Hammer.defaults, options || {});
|
27830 | this.options.inputTarget = this.options.inputTarget || element;
|
27831 | this.handlers = {};
|
27832 | this.session = {};
|
27833 | this.recognizers = [];
|
27834 | this.oldCssProps = {};
|
27835 | this.element = element;
|
27836 | this.input = createInputInstance(this);
|
27837 | this.touchAction = new TouchAction(this, this.options.touchAction);
|
27838 | toggleCssProps(this, true);
|
27839 | each(this.options.recognizers, function (item) {
|
27840 | var recognizer = this.add(new item[0](item[1]));
|
27841 | item[2] && recognizer.recognizeWith(item[2]);
|
27842 | item[3] && recognizer.requireFailure(item[3]);
|
27843 | }, this);
|
27844 | }
|
27845 |
|
27846 | Manager.prototype = {
|
27847 | |
27848 |
|
27849 |
|
27850 |
|
27851 |
|
27852 | set: function (options) {
|
27853 | assign(this.options, options);
|
27854 |
|
27855 | if (options.touchAction) {
|
27856 | this.touchAction.update();
|
27857 | }
|
27858 |
|
27859 | if (options.inputTarget) {
|
27860 |
|
27861 | this.input.destroy();
|
27862 | this.input.target = options.inputTarget;
|
27863 | this.input.init();
|
27864 | }
|
27865 |
|
27866 | return this;
|
27867 | },
|
27868 |
|
27869 | |
27870 |
|
27871 |
|
27872 |
|
27873 |
|
27874 |
|
27875 | stop: function (force) {
|
27876 | this.session.stopped = force ? FORCED_STOP : STOP;
|
27877 | },
|
27878 |
|
27879 | |
27880 |
|
27881 |
|
27882 |
|
27883 |
|
27884 |
|
27885 | recognize: function (inputData) {
|
27886 | var session = this.session;
|
27887 |
|
27888 | if (session.stopped) {
|
27889 | return;
|
27890 | }
|
27891 |
|
27892 |
|
27893 | this.touchAction.preventDefaults(inputData);
|
27894 | var recognizer;
|
27895 | var recognizers = this.recognizers;
|
27896 |
|
27897 |
|
27898 |
|
27899 | var curRecognizer = session.curRecognizer;
|
27900 |
|
27901 |
|
27902 | if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
|
27903 | curRecognizer = session.curRecognizer = null;
|
27904 | }
|
27905 |
|
27906 | var i = 0;
|
27907 |
|
27908 | while (i < recognizers.length) {
|
27909 | recognizer = recognizers[i];
|
27910 |
|
27911 |
|
27912 |
|
27913 |
|
27914 |
|
27915 |
|
27916 | if (session.stopped !== FORCED_STOP && (
|
27917 | !curRecognizer || recognizer == curRecognizer ||
|
27918 | recognizer.canRecognizeWith(curRecognizer))) {
|
27919 |
|
27920 | recognizer.recognize(inputData);
|
27921 | } else {
|
27922 | recognizer.reset();
|
27923 | }
|
27924 |
|
27925 |
|
27926 |
|
27927 | if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
27928 | curRecognizer = session.curRecognizer = recognizer;
|
27929 | }
|
27930 |
|
27931 | i++;
|
27932 | }
|
27933 | },
|
27934 |
|
27935 | |
27936 |
|
27937 |
|
27938 |
|
27939 |
|
27940 | get: function (recognizer) {
|
27941 | if (recognizer instanceof Recognizer) {
|
27942 | return recognizer;
|
27943 | }
|
27944 |
|
27945 | var recognizers = this.recognizers;
|
27946 |
|
27947 | for (var i = 0; i < recognizers.length; i++) {
|
27948 | if (recognizers[i].options.event == recognizer) {
|
27949 | return recognizers[i];
|
27950 | }
|
27951 | }
|
27952 |
|
27953 | return null;
|
27954 | },
|
27955 |
|
27956 | |
27957 |
|
27958 |
|
27959 |
|
27960 |
|
27961 |
|
27962 | add: function (recognizer) {
|
27963 | if (invokeArrayArg(recognizer, 'add', this)) {
|
27964 | return this;
|
27965 | }
|
27966 |
|
27967 |
|
27968 | var existing = this.get(recognizer.options.event);
|
27969 |
|
27970 | if (existing) {
|
27971 | this.remove(existing);
|
27972 | }
|
27973 |
|
27974 | this.recognizers.push(recognizer);
|
27975 | recognizer.manager = this;
|
27976 | this.touchAction.update();
|
27977 | return recognizer;
|
27978 | },
|
27979 |
|
27980 | |
27981 |
|
27982 |
|
27983 |
|
27984 |
|
27985 | remove: function (recognizer) {
|
27986 | if (invokeArrayArg(recognizer, 'remove', this)) {
|
27987 | return this;
|
27988 | }
|
27989 |
|
27990 | recognizer = this.get(recognizer);
|
27991 |
|
27992 | if (recognizer) {
|
27993 | var recognizers = this.recognizers;
|
27994 | var index = inArray(recognizers, recognizer);
|
27995 |
|
27996 | if (index !== -1) {
|
27997 | recognizers.splice(index, 1);
|
27998 | this.touchAction.update();
|
27999 | }
|
28000 | }
|
28001 |
|
28002 | return this;
|
28003 | },
|
28004 |
|
28005 | |
28006 |
|
28007 |
|
28008 |
|
28009 |
|
28010 |
|
28011 | on: function (events, handler) {
|
28012 | if (events === undefined$1) {
|
28013 | return;
|
28014 | }
|
28015 |
|
28016 | if (handler === undefined$1) {
|
28017 | return;
|
28018 | }
|
28019 |
|
28020 | var handlers = this.handlers;
|
28021 | each(splitStr(events), function (event) {
|
28022 | handlers[event] = handlers[event] || [];
|
28023 | handlers[event].push(handler);
|
28024 | });
|
28025 | return this;
|
28026 | },
|
28027 |
|
28028 | |
28029 |
|
28030 |
|
28031 |
|
28032 |
|
28033 |
|
28034 | off: function (events, handler) {
|
28035 | if (events === undefined$1) {
|
28036 | return;
|
28037 | }
|
28038 |
|
28039 | var handlers = this.handlers;
|
28040 | each(splitStr(events), function (event) {
|
28041 | if (!handler) {
|
28042 | delete handlers[event];
|
28043 | } else {
|
28044 | handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
28045 | }
|
28046 | });
|
28047 | return this;
|
28048 | },
|
28049 |
|
28050 | |
28051 |
|
28052 |
|
28053 |
|
28054 |
|
28055 | emit: function (event, data) {
|
28056 |
|
28057 | if (this.options.domEvents) {
|
28058 | triggerDomEvent(event, data);
|
28059 | }
|
28060 |
|
28061 |
|
28062 | var handlers = this.handlers[event] && this.handlers[event].slice();
|
28063 |
|
28064 | if (!handlers || !handlers.length) {
|
28065 | return;
|
28066 | }
|
28067 |
|
28068 | data.type = event;
|
28069 |
|
28070 | data.preventDefault = function () {
|
28071 | data.srcEvent.preventDefault();
|
28072 | };
|
28073 |
|
28074 | var i = 0;
|
28075 |
|
28076 | while (i < handlers.length) {
|
28077 | handlers[i](data);
|
28078 | i++;
|
28079 | }
|
28080 | },
|
28081 |
|
28082 | |
28083 |
|
28084 |
|
28085 |
|
28086 | destroy: function () {
|
28087 | this.element && toggleCssProps(this, false);
|
28088 | this.handlers = {};
|
28089 | this.session = {};
|
28090 | this.input.destroy();
|
28091 | this.element = null;
|
28092 | }
|
28093 | };
|
28094 | |
28095 |
|
28096 |
|
28097 |
|
28098 |
|
28099 |
|
28100 | function toggleCssProps(manager, add) {
|
28101 | var element = manager.element;
|
28102 |
|
28103 | if (!element.style) {
|
28104 | return;
|
28105 | }
|
28106 |
|
28107 | var prop;
|
28108 | each(manager.options.cssProps, function (value, name) {
|
28109 | prop = prefixed(element.style, name);
|
28110 |
|
28111 | if (add) {
|
28112 | manager.oldCssProps[prop] = element.style[prop];
|
28113 | element.style[prop] = value;
|
28114 | } else {
|
28115 | element.style[prop] = manager.oldCssProps[prop] || '';
|
28116 | }
|
28117 | });
|
28118 |
|
28119 | if (!add) {
|
28120 | manager.oldCssProps = {};
|
28121 | }
|
28122 | }
|
28123 | |
28124 |
|
28125 |
|
28126 |
|
28127 |
|
28128 |
|
28129 |
|
28130 | function triggerDomEvent(event, data) {
|
28131 | var gestureEvent = document.createEvent('Event');
|
28132 | gestureEvent.initEvent(event, true, true);
|
28133 | gestureEvent.gesture = data;
|
28134 | data.target.dispatchEvent(gestureEvent);
|
28135 | }
|
28136 |
|
28137 | assign(Hammer, {
|
28138 | INPUT_START: INPUT_START,
|
28139 | INPUT_MOVE: INPUT_MOVE,
|
28140 | INPUT_END: INPUT_END,
|
28141 | INPUT_CANCEL: INPUT_CANCEL,
|
28142 | STATE_POSSIBLE: STATE_POSSIBLE,
|
28143 | STATE_BEGAN: STATE_BEGAN,
|
28144 | STATE_CHANGED: STATE_CHANGED,
|
28145 | STATE_ENDED: STATE_ENDED,
|
28146 | STATE_RECOGNIZED: STATE_RECOGNIZED,
|
28147 | STATE_CANCELLED: STATE_CANCELLED,
|
28148 | STATE_FAILED: STATE_FAILED,
|
28149 | DIRECTION_NONE: DIRECTION_NONE,
|
28150 | DIRECTION_LEFT: DIRECTION_LEFT,
|
28151 | DIRECTION_RIGHT: DIRECTION_RIGHT,
|
28152 | DIRECTION_UP: DIRECTION_UP,
|
28153 | DIRECTION_DOWN: DIRECTION_DOWN,
|
28154 | DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
|
28155 | DIRECTION_VERTICAL: DIRECTION_VERTICAL,
|
28156 | DIRECTION_ALL: DIRECTION_ALL,
|
28157 | Manager: Manager,
|
28158 | Input: Input,
|
28159 | TouchAction: TouchAction,
|
28160 | TouchInput: TouchInput,
|
28161 | MouseInput: MouseInput,
|
28162 | PointerEventInput: PointerEventInput,
|
28163 | TouchMouseInput: TouchMouseInput,
|
28164 | SingleTouchInput: SingleTouchInput,
|
28165 | Recognizer: Recognizer,
|
28166 | AttrRecognizer: AttrRecognizer,
|
28167 | Tap: TapRecognizer,
|
28168 | Pan: PanRecognizer,
|
28169 | Swipe: SwipeRecognizer,
|
28170 | Pinch: PinchRecognizer,
|
28171 | Rotate: RotateRecognizer,
|
28172 | Press: PressRecognizer,
|
28173 | on: addEventListeners,
|
28174 | off: removeEventListeners,
|
28175 | each: each,
|
28176 | merge: merge,
|
28177 | extend: extend,
|
28178 | assign: assign,
|
28179 | inherit: inherit,
|
28180 | bindFn: bindFn,
|
28181 | prefixed: prefixed
|
28182 | });
|
28183 |
|
28184 |
|
28185 | var freeGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {};
|
28186 |
|
28187 | freeGlobal.Hammer = Hammer;
|
28188 |
|
28189 | if (typeof undefined$1 === 'function' && undefined$1.amd) {
|
28190 | undefined$1(function () {
|
28191 | return Hammer;
|
28192 | });
|
28193 | } else if ( module.exports) {
|
28194 | module.exports = Hammer;
|
28195 | } else {
|
28196 | window[exportName] = Hammer;
|
28197 | }
|
28198 | })(window, document, 'Hammer');
|
28199 | });
|
28200 |
|
28201 | var hammer$1 = createCommonjsModule$1(function (module) {
|
28202 | |
28203 |
|
28204 |
|
28205 |
|
28206 |
|
28207 |
|
28208 |
|
28209 | function hammerMock() {
|
28210 | var noop = function noop() {};
|
28211 |
|
28212 | return {
|
28213 | on: noop,
|
28214 | off: noop,
|
28215 | destroy: noop,
|
28216 | emit: noop,
|
28217 | get: function get(m) {
|
28218 |
|
28219 | return {
|
28220 | set: noop
|
28221 | };
|
28222 | }
|
28223 | };
|
28224 | }
|
28225 |
|
28226 | if (typeof window !== 'undefined') {
|
28227 | var propagating$1 = propagating;
|
28228 | var Hammer = window['Hammer'] || hammer;
|
28229 | module.exports = propagating$1(Hammer, {
|
28230 | preventDefault: 'mouse'
|
28231 | });
|
28232 | } else {
|
28233 | module.exports = function () {
|
28234 |
|
28235 | return hammerMock();
|
28236 | };
|
28237 | }
|
28238 | });
|
28239 |
|
28240 | var keycharm = createCommonjsModule$1(function (module, exports) {
|
28241 | |
28242 |
|
28243 |
|
28244 |
|
28245 |
|
28246 |
|
28247 | (function (root, factory) {
|
28248 | {
|
28249 |
|
28250 |
|
28251 |
|
28252 | module.exports = factory();
|
28253 | }
|
28254 | })(commonjsGlobal$1, function () {
|
28255 | function keycharm(options) {
|
28256 | var preventDefault = options && options.preventDefault || false;
|
28257 | var container = options && options.container || window;
|
28258 | var _exportFunctions = {};
|
28259 | var _bound = {
|
28260 | keydown: {},
|
28261 | keyup: {}
|
28262 | };
|
28263 | var _keys = {};
|
28264 | var i;
|
28265 |
|
28266 | for (i = 97; i <= 122; i++) {
|
28267 | _keys[String.fromCharCode(i)] = {
|
28268 | code: 65 + (i - 97),
|
28269 | shift: false
|
28270 | };
|
28271 | }
|
28272 |
|
28273 |
|
28274 | for (i = 65; i <= 90; i++) {
|
28275 | _keys[String.fromCharCode(i)] = {
|
28276 | code: i,
|
28277 | shift: true
|
28278 | };
|
28279 | }
|
28280 |
|
28281 |
|
28282 | for (i = 0; i <= 9; i++) {
|
28283 | _keys['' + i] = {
|
28284 | code: 48 + i,
|
28285 | shift: false
|
28286 | };
|
28287 | }
|
28288 |
|
28289 |
|
28290 | for (i = 1; i <= 12; i++) {
|
28291 | _keys['F' + i] = {
|
28292 | code: 111 + i,
|
28293 | shift: false
|
28294 | };
|
28295 | }
|
28296 |
|
28297 |
|
28298 | for (i = 0; i <= 9; i++) {
|
28299 | _keys['num' + i] = {
|
28300 | code: 96 + i,
|
28301 | shift: false
|
28302 | };
|
28303 | }
|
28304 |
|
28305 |
|
28306 | _keys['num*'] = {
|
28307 | code: 106,
|
28308 | shift: false
|
28309 | };
|
28310 | _keys['num+'] = {
|
28311 | code: 107,
|
28312 | shift: false
|
28313 | };
|
28314 | _keys['num-'] = {
|
28315 | code: 109,
|
28316 | shift: false
|
28317 | };
|
28318 | _keys['num/'] = {
|
28319 | code: 111,
|
28320 | shift: false
|
28321 | };
|
28322 | _keys['num.'] = {
|
28323 | code: 110,
|
28324 | shift: false
|
28325 | };
|
28326 |
|
28327 | _keys['left'] = {
|
28328 | code: 37,
|
28329 | shift: false
|
28330 | };
|
28331 | _keys['up'] = {
|
28332 | code: 38,
|
28333 | shift: false
|
28334 | };
|
28335 | _keys['right'] = {
|
28336 | code: 39,
|
28337 | shift: false
|
28338 | };
|
28339 | _keys['down'] = {
|
28340 | code: 40,
|
28341 | shift: false
|
28342 | };
|
28343 |
|
28344 | _keys['space'] = {
|
28345 | code: 32,
|
28346 | shift: false
|
28347 | };
|
28348 | _keys['enter'] = {
|
28349 | code: 13,
|
28350 | shift: false
|
28351 | };
|
28352 | _keys['shift'] = {
|
28353 | code: 16,
|
28354 | shift: undefined
|
28355 | };
|
28356 | _keys['esc'] = {
|
28357 | code: 27,
|
28358 | shift: false
|
28359 | };
|
28360 | _keys['backspace'] = {
|
28361 | code: 8,
|
28362 | shift: false
|
28363 | };
|
28364 | _keys['tab'] = {
|
28365 | code: 9,
|
28366 | shift: false
|
28367 | };
|
28368 | _keys['ctrl'] = {
|
28369 | code: 17,
|
28370 | shift: false
|
28371 | };
|
28372 | _keys['alt'] = {
|
28373 | code: 18,
|
28374 | shift: false
|
28375 | };
|
28376 | _keys['delete'] = {
|
28377 | code: 46,
|
28378 | shift: false
|
28379 | };
|
28380 | _keys['pageup'] = {
|
28381 | code: 33,
|
28382 | shift: false
|
28383 | };
|
28384 | _keys['pagedown'] = {
|
28385 | code: 34,
|
28386 | shift: false
|
28387 | };
|
28388 |
|
28389 | _keys['='] = {
|
28390 | code: 187,
|
28391 | shift: false
|
28392 | };
|
28393 | _keys['-'] = {
|
28394 | code: 189,
|
28395 | shift: false
|
28396 | };
|
28397 | _keys[']'] = {
|
28398 | code: 221,
|
28399 | shift: false
|
28400 | };
|
28401 | _keys['['] = {
|
28402 | code: 219,
|
28403 | shift: false
|
28404 | };
|
28405 |
|
28406 | var down = function (event) {
|
28407 | handleEvent(event, 'keydown');
|
28408 | };
|
28409 |
|
28410 | var up = function (event) {
|
28411 | handleEvent(event, 'keyup');
|
28412 | };
|
28413 |
|
28414 |
|
28415 | var handleEvent = function (event, type) {
|
28416 | if (_bound[type][event.keyCode] !== undefined) {
|
28417 | var bound = _bound[type][event.keyCode];
|
28418 |
|
28419 | for (var i = 0; i < bound.length; i++) {
|
28420 | if (bound[i].shift === undefined) {
|
28421 | bound[i].fn(event);
|
28422 | } else if (bound[i].shift == true && event.shiftKey == true) {
|
28423 | bound[i].fn(event);
|
28424 | } else if (bound[i].shift == false && event.shiftKey == false) {
|
28425 | bound[i].fn(event);
|
28426 | }
|
28427 | }
|
28428 |
|
28429 | if (preventDefault == true) {
|
28430 | event.preventDefault();
|
28431 | }
|
28432 | }
|
28433 | };
|
28434 |
|
28435 |
|
28436 | _exportFunctions.bind = function (key, callback, type) {
|
28437 | if (type === undefined) {
|
28438 | type = 'keydown';
|
28439 | }
|
28440 |
|
28441 | if (_keys[key] === undefined) {
|
28442 | throw new Error("unsupported key: " + key);
|
28443 | }
|
28444 |
|
28445 | if (_bound[type][_keys[key].code] === undefined) {
|
28446 | _bound[type][_keys[key].code] = [];
|
28447 | }
|
28448 |
|
28449 | _bound[type][_keys[key].code].push({
|
28450 | fn: callback,
|
28451 | shift: _keys[key].shift
|
28452 | });
|
28453 | };
|
28454 |
|
28455 |
|
28456 | _exportFunctions.bindAll = function (callback, type) {
|
28457 | if (type === undefined) {
|
28458 | type = 'keydown';
|
28459 | }
|
28460 |
|
28461 | for (var key in _keys) {
|
28462 | if (_keys.hasOwnProperty(key)) {
|
28463 | _exportFunctions.bind(key, callback, type);
|
28464 | }
|
28465 | }
|
28466 | };
|
28467 |
|
28468 |
|
28469 | _exportFunctions.getKey = function (event) {
|
28470 | for (var key in _keys) {
|
28471 | if (_keys.hasOwnProperty(key)) {
|
28472 | if (event.shiftKey == true && _keys[key].shift == true && event.keyCode == _keys[key].code) {
|
28473 | return key;
|
28474 | } else if (event.shiftKey == false && _keys[key].shift == false && event.keyCode == _keys[key].code) {
|
28475 | return key;
|
28476 | } else if (event.keyCode == _keys[key].code && key == 'shift') {
|
28477 | return key;
|
28478 | }
|
28479 | }
|
28480 | }
|
28481 |
|
28482 | return "unknown key, currently not supported";
|
28483 | };
|
28484 |
|
28485 |
|
28486 | _exportFunctions.unbind = function (key, callback, type) {
|
28487 | if (type === undefined) {
|
28488 | type = 'keydown';
|
28489 | }
|
28490 |
|
28491 | if (_keys[key] === undefined) {
|
28492 | throw new Error("unsupported key: " + key);
|
28493 | }
|
28494 |
|
28495 | if (callback !== undefined) {
|
28496 | var newBindings = [];
|
28497 | var bound = _bound[type][_keys[key].code];
|
28498 |
|
28499 | if (bound !== undefined) {
|
28500 | for (var i = 0; i < bound.length; i++) {
|
28501 | if (!(bound[i].fn == callback && bound[i].shift == _keys[key].shift)) {
|
28502 | newBindings.push(_bound[type][_keys[key].code][i]);
|
28503 | }
|
28504 | }
|
28505 | }
|
28506 |
|
28507 | _bound[type][_keys[key].code] = newBindings;
|
28508 | } else {
|
28509 | _bound[type][_keys[key].code] = [];
|
28510 | }
|
28511 | };
|
28512 |
|
28513 |
|
28514 | _exportFunctions.reset = function () {
|
28515 | _bound = {
|
28516 | keydown: {},
|
28517 | keyup: {}
|
28518 | };
|
28519 | };
|
28520 |
|
28521 |
|
28522 | _exportFunctions.destroy = function () {
|
28523 | _bound = {
|
28524 | keydown: {},
|
28525 | keyup: {}
|
28526 | };
|
28527 | container.removeEventListener('keydown', down, true);
|
28528 | container.removeEventListener('keyup', up, true);
|
28529 | };
|
28530 |
|
28531 |
|
28532 | container.addEventListener('keydown', down, true);
|
28533 | container.addEventListener('keyup', up, true);
|
28534 |
|
28535 | return _exportFunctions;
|
28536 | }
|
28537 |
|
28538 | return keycharm;
|
28539 | });
|
28540 | });
|
28541 |
|
28542 | var util_1 = util;
|
28543 | var DOMutil$1 = DOMutil;
|
28544 |
|
28545 | var DataSet$3 = visData.DataSet,
|
28546 | DataView$4 = visData.DataView,
|
28547 | Queue$2 = visData.Queue;
|
28548 | var DataSet_1$1 = DataSet$3;
|
28549 | var DataView_1 = DataView$4;
|
28550 | var Queue_1$1 = Queue$2;
|
28551 |
|
28552 | var Graph3d$1 = Graph3d_1;
|
28553 | var graph3d = {
|
28554 | Camera: Camera_1,
|
28555 | Filter: Filter_1,
|
28556 | Point2d: Point2d_1,
|
28557 | Point3d: Point3d_1,
|
28558 | Slider: Slider_1,
|
28559 | StepNumber: StepNumber_1
|
28560 | };
|
28561 |
|
28562 | var moment$4 = moment$3;
|
28563 | var Hammer = hammer$1;
|
28564 | var keycharm$1 = keycharm;
|
28565 | var visGraph3d = {
|
28566 | util: util_1,
|
28567 | DOMutil: DOMutil$1,
|
28568 | DataSet: DataSet_1$1,
|
28569 | DataView: DataView_1,
|
28570 | Queue: Queue_1$1,
|
28571 | Graph3d: Graph3d$1,
|
28572 | graph3d: graph3d,
|
28573 | moment: moment$4,
|
28574 | Hammer: Hammer,
|
28575 | keycharm: keycharm$1
|
28576 | };
|
28577 |
|
28578 | export default visGraph3d;
|
28579 | export { DOMutil$1 as DOMutil, DataSet_1$1 as DataSet, DataView_1 as DataView, Graph3d$1 as Graph3d, Hammer, Queue_1$1 as Queue, graph3d, keycharm$1 as keycharm, moment$4 as moment, util_1 as util };
|