UNPKG

38.6 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) :
3 typeof define === 'function' && define.amd ? define(['jquery'], factory) :
4 (global = global || self, factory(global.jQuery));
5}(this, function ($) { 'use strict';
6
7 $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
8
9 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
11 function createCommonjsModule(fn, module) {
12 return module = { exports: {} }, fn(module, module.exports), module.exports;
13 }
14
15 var O = 'object';
16 var check = function (it) {
17 return it && it.Math == Math && it;
18 };
19
20 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
21 var global_1 =
22 // eslint-disable-next-line no-undef
23 check(typeof globalThis == O && globalThis) ||
24 check(typeof window == O && window) ||
25 check(typeof self == O && self) ||
26 check(typeof commonjsGlobal == O && commonjsGlobal) ||
27 // eslint-disable-next-line no-new-func
28 Function('return this')();
29
30 var fails = function (exec) {
31 try {
32 return !!exec();
33 } catch (error) {
34 return true;
35 }
36 };
37
38 // Thank's IE8 for his funny defineProperty
39 var descriptors = !fails(function () {
40 return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
41 });
42
43 var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
44 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
45
46 // Nashorn ~ JDK8 bug
47 var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
48
49 // `Object.prototype.propertyIsEnumerable` method implementation
50 // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
51 var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
52 var descriptor = getOwnPropertyDescriptor(this, V);
53 return !!descriptor && descriptor.enumerable;
54 } : nativePropertyIsEnumerable;
55
56 var objectPropertyIsEnumerable = {
57 f: f
58 };
59
60 var createPropertyDescriptor = function (bitmap, value) {
61 return {
62 enumerable: !(bitmap & 1),
63 configurable: !(bitmap & 2),
64 writable: !(bitmap & 4),
65 value: value
66 };
67 };
68
69 var toString = {}.toString;
70
71 var classofRaw = function (it) {
72 return toString.call(it).slice(8, -1);
73 };
74
75 var split = ''.split;
76
77 // fallback for non-array-like ES3 and non-enumerable old V8 strings
78 var indexedObject = fails(function () {
79 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
80 // eslint-disable-next-line no-prototype-builtins
81 return !Object('z').propertyIsEnumerable(0);
82 }) ? function (it) {
83 return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
84 } : Object;
85
86 // `RequireObjectCoercible` abstract operation
87 // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
88 var requireObjectCoercible = function (it) {
89 if (it == undefined) throw TypeError("Can't call method on " + it);
90 return it;
91 };
92
93 // toObject with fallback for non-array-like ES3 strings
94
95
96
97 var toIndexedObject = function (it) {
98 return indexedObject(requireObjectCoercible(it));
99 };
100
101 var isObject = function (it) {
102 return typeof it === 'object' ? it !== null : typeof it === 'function';
103 };
104
105 // `ToPrimitive` abstract operation
106 // https://tc39.github.io/ecma262/#sec-toprimitive
107 // instead of the ES6 spec version, we didn't implement @@toPrimitive case
108 // and the second argument - flag - preferred type is a string
109 var toPrimitive = function (input, PREFERRED_STRING) {
110 if (!isObject(input)) return input;
111 var fn, val;
112 if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
113 if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
114 if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
115 throw TypeError("Can't convert object to primitive value");
116 };
117
118 var hasOwnProperty = {}.hasOwnProperty;
119
120 var has = function (it, key) {
121 return hasOwnProperty.call(it, key);
122 };
123
124 var document = global_1.document;
125 // typeof document.createElement is 'object' in old IE
126 var EXISTS = isObject(document) && isObject(document.createElement);
127
128 var documentCreateElement = function (it) {
129 return EXISTS ? document.createElement(it) : {};
130 };
131
132 // Thank's IE8 for his funny defineProperty
133 var ie8DomDefine = !descriptors && !fails(function () {
134 return Object.defineProperty(documentCreateElement('div'), 'a', {
135 get: function () { return 7; }
136 }).a != 7;
137 });
138
139 var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
140
141 // `Object.getOwnPropertyDescriptor` method
142 // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
143 var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
144 O = toIndexedObject(O);
145 P = toPrimitive(P, true);
146 if (ie8DomDefine) try {
147 return nativeGetOwnPropertyDescriptor(O, P);
148 } catch (error) { /* empty */ }
149 if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
150 };
151
152 var objectGetOwnPropertyDescriptor = {
153 f: f$1
154 };
155
156 var anObject = function (it) {
157 if (!isObject(it)) {
158 throw TypeError(String(it) + ' is not an object');
159 } return it;
160 };
161
162 var nativeDefineProperty = Object.defineProperty;
163
164 // `Object.defineProperty` method
165 // https://tc39.github.io/ecma262/#sec-object.defineproperty
166 var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
167 anObject(O);
168 P = toPrimitive(P, true);
169 anObject(Attributes);
170 if (ie8DomDefine) try {
171 return nativeDefineProperty(O, P, Attributes);
172 } catch (error) { /* empty */ }
173 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
174 if ('value' in Attributes) O[P] = Attributes.value;
175 return O;
176 };
177
178 var objectDefineProperty = {
179 f: f$2
180 };
181
182 var hide = descriptors ? function (object, key, value) {
183 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
184 } : function (object, key, value) {
185 object[key] = value;
186 return object;
187 };
188
189 var setGlobal = function (key, value) {
190 try {
191 hide(global_1, key, value);
192 } catch (error) {
193 global_1[key] = value;
194 } return value;
195 };
196
197 var shared = createCommonjsModule(function (module) {
198 var SHARED = '__core-js_shared__';
199 var store = global_1[SHARED] || setGlobal(SHARED, {});
200
201 (module.exports = function (key, value) {
202 return store[key] || (store[key] = value !== undefined ? value : {});
203 })('versions', []).push({
204 version: '3.1.3',
205 mode: 'global',
206 copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
207 });
208 });
209
210 var functionToString = shared('native-function-to-string', Function.toString);
211
212 var WeakMap = global_1.WeakMap;
213
214 var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(functionToString.call(WeakMap));
215
216 var id = 0;
217 var postfix = Math.random();
218
219 var uid = function (key) {
220 return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
221 };
222
223 var keys = shared('keys');
224
225 var sharedKey = function (key) {
226 return keys[key] || (keys[key] = uid(key));
227 };
228
229 var hiddenKeys = {};
230
231 var WeakMap$1 = global_1.WeakMap;
232 var set, get, has$1;
233
234 var enforce = function (it) {
235 return has$1(it) ? get(it) : set(it, {});
236 };
237
238 var getterFor = function (TYPE) {
239 return function (it) {
240 var state;
241 if (!isObject(it) || (state = get(it)).type !== TYPE) {
242 throw TypeError('Incompatible receiver, ' + TYPE + ' required');
243 } return state;
244 };
245 };
246
247 if (nativeWeakMap) {
248 var store = new WeakMap$1();
249 var wmget = store.get;
250 var wmhas = store.has;
251 var wmset = store.set;
252 set = function (it, metadata) {
253 wmset.call(store, it, metadata);
254 return metadata;
255 };
256 get = function (it) {
257 return wmget.call(store, it) || {};
258 };
259 has$1 = function (it) {
260 return wmhas.call(store, it);
261 };
262 } else {
263 var STATE = sharedKey('state');
264 hiddenKeys[STATE] = true;
265 set = function (it, metadata) {
266 hide(it, STATE, metadata);
267 return metadata;
268 };
269 get = function (it) {
270 return has(it, STATE) ? it[STATE] : {};
271 };
272 has$1 = function (it) {
273 return has(it, STATE);
274 };
275 }
276
277 var internalState = {
278 set: set,
279 get: get,
280 has: has$1,
281 enforce: enforce,
282 getterFor: getterFor
283 };
284
285 var redefine = createCommonjsModule(function (module) {
286 var getInternalState = internalState.get;
287 var enforceInternalState = internalState.enforce;
288 var TEMPLATE = String(functionToString).split('toString');
289
290 shared('inspectSource', function (it) {
291 return functionToString.call(it);
292 });
293
294 (module.exports = function (O, key, value, options) {
295 var unsafe = options ? !!options.unsafe : false;
296 var simple = options ? !!options.enumerable : false;
297 var noTargetGet = options ? !!options.noTargetGet : false;
298 if (typeof value == 'function') {
299 if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
300 enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
301 }
302 if (O === global_1) {
303 if (simple) O[key] = value;
304 else setGlobal(key, value);
305 return;
306 } else if (!unsafe) {
307 delete O[key];
308 } else if (!noTargetGet && O[key]) {
309 simple = true;
310 }
311 if (simple) O[key] = value;
312 else hide(O, key, value);
313 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
314 })(Function.prototype, 'toString', function toString() {
315 return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
316 });
317 });
318
319 var path = global_1;
320
321 var aFunction = function (variable) {
322 return typeof variable == 'function' ? variable : undefined;
323 };
324
325 var getBuiltIn = function (namespace, method) {
326 return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
327 : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
328 };
329
330 var ceil = Math.ceil;
331 var floor = Math.floor;
332
333 // `ToInteger` abstract operation
334 // https://tc39.github.io/ecma262/#sec-tointeger
335 var toInteger = function (argument) {
336 return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
337 };
338
339 var min = Math.min;
340
341 // `ToLength` abstract operation
342 // https://tc39.github.io/ecma262/#sec-tolength
343 var toLength = function (argument) {
344 return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
345 };
346
347 var max = Math.max;
348 var min$1 = Math.min;
349
350 // Helper for a popular repeating case of the spec:
351 // Let integer be ? ToInteger(index).
352 // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
353 var toAbsoluteIndex = function (index, length) {
354 var integer = toInteger(index);
355 return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
356 };
357
358 // `Array.prototype.{ indexOf, includes }` methods implementation
359 var createMethod = function (IS_INCLUDES) {
360 return function ($this, el, fromIndex) {
361 var O = toIndexedObject($this);
362 var length = toLength(O.length);
363 var index = toAbsoluteIndex(fromIndex, length);
364 var value;
365 // Array#includes uses SameValueZero equality algorithm
366 // eslint-disable-next-line no-self-compare
367 if (IS_INCLUDES && el != el) while (length > index) {
368 value = O[index++];
369 // eslint-disable-next-line no-self-compare
370 if (value != value) return true;
371 // Array#indexOf ignores holes, Array#includes - not
372 } else for (;length > index; index++) {
373 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
374 } return !IS_INCLUDES && -1;
375 };
376 };
377
378 var arrayIncludes = {
379 // `Array.prototype.includes` method
380 // https://tc39.github.io/ecma262/#sec-array.prototype.includes
381 includes: createMethod(true),
382 // `Array.prototype.indexOf` method
383 // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
384 indexOf: createMethod(false)
385 };
386
387 var indexOf = arrayIncludes.indexOf;
388
389
390 var objectKeysInternal = function (object, names) {
391 var O = toIndexedObject(object);
392 var i = 0;
393 var result = [];
394 var key;
395 for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
396 // Don't enum bug & hidden keys
397 while (names.length > i) if (has(O, key = names[i++])) {
398 ~indexOf(result, key) || result.push(key);
399 }
400 return result;
401 };
402
403 // IE8- don't enum bug keys
404 var enumBugKeys = [
405 'constructor',
406 'hasOwnProperty',
407 'isPrototypeOf',
408 'propertyIsEnumerable',
409 'toLocaleString',
410 'toString',
411 'valueOf'
412 ];
413
414 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
415
416 // `Object.getOwnPropertyNames` method
417 // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
418 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
419 return objectKeysInternal(O, hiddenKeys$1);
420 };
421
422 var objectGetOwnPropertyNames = {
423 f: f$3
424 };
425
426 var f$4 = Object.getOwnPropertySymbols;
427
428 var objectGetOwnPropertySymbols = {
429 f: f$4
430 };
431
432 // all object keys, includes non-enumerable and symbols
433 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
434 var keys = objectGetOwnPropertyNames.f(anObject(it));
435 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
436 return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
437 };
438
439 var copyConstructorProperties = function (target, source) {
440 var keys = ownKeys(source);
441 var defineProperty = objectDefineProperty.f;
442 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
443 for (var i = 0; i < keys.length; i++) {
444 var key = keys[i];
445 if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
446 }
447 };
448
449 var replacement = /#|\.prototype\./;
450
451 var isForced = function (feature, detection) {
452 var value = data[normalize(feature)];
453 return value == POLYFILL ? true
454 : value == NATIVE ? false
455 : typeof detection == 'function' ? fails(detection)
456 : !!detection;
457 };
458
459 var normalize = isForced.normalize = function (string) {
460 return String(string).replace(replacement, '.').toLowerCase();
461 };
462
463 var data = isForced.data = {};
464 var NATIVE = isForced.NATIVE = 'N';
465 var POLYFILL = isForced.POLYFILL = 'P';
466
467 var isForced_1 = isForced;
468
469 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
470
471
472
473
474
475
476 /*
477 options.target - name of the target object
478 options.global - target is the global object
479 options.stat - export as static methods of target
480 options.proto - export as prototype methods of target
481 options.real - real prototype method for the `pure` version
482 options.forced - export even if the native feature is available
483 options.bind - bind methods to the target, required for the `pure` version
484 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
485 options.unsafe - use the simple assignment of property instead of delete + defineProperty
486 options.sham - add a flag to not completely full polyfills
487 options.enumerable - export as enumerable property
488 options.noTargetGet - prevent calling a getter on target
489 */
490 var _export = function (options, source) {
491 var TARGET = options.target;
492 var GLOBAL = options.global;
493 var STATIC = options.stat;
494 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
495 if (GLOBAL) {
496 target = global_1;
497 } else if (STATIC) {
498 target = global_1[TARGET] || setGlobal(TARGET, {});
499 } else {
500 target = (global_1[TARGET] || {}).prototype;
501 }
502 if (target) for (key in source) {
503 sourceProperty = source[key];
504 if (options.noTargetGet) {
505 descriptor = getOwnPropertyDescriptor$1(target, key);
506 targetProperty = descriptor && descriptor.value;
507 } else targetProperty = target[key];
508 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
509 // contained in target
510 if (!FORCED && targetProperty !== undefined) {
511 if (typeof sourceProperty === typeof targetProperty) continue;
512 copyConstructorProperties(sourceProperty, targetProperty);
513 }
514 // add a flag to not completely full polyfills
515 if (options.sham || (targetProperty && targetProperty.sham)) {
516 hide(sourceProperty, 'sham', true);
517 }
518 // extend global
519 redefine(target, key, sourceProperty, options);
520 }
521 };
522
523 var aFunction$1 = function (it) {
524 if (typeof it != 'function') {
525 throw TypeError(String(it) + ' is not a function');
526 } return it;
527 };
528
529 // optional / simple context binding
530 var bindContext = function (fn, that, length) {
531 aFunction$1(fn);
532 if (that === undefined) return fn;
533 switch (length) {
534 case 0: return function () {
535 return fn.call(that);
536 };
537 case 1: return function (a) {
538 return fn.call(that, a);
539 };
540 case 2: return function (a, b) {
541 return fn.call(that, a, b);
542 };
543 case 3: return function (a, b, c) {
544 return fn.call(that, a, b, c);
545 };
546 }
547 return function (/* ...args */) {
548 return fn.apply(that, arguments);
549 };
550 };
551
552 // `ToObject` abstract operation
553 // https://tc39.github.io/ecma262/#sec-toobject
554 var toObject = function (argument) {
555 return Object(requireObjectCoercible(argument));
556 };
557
558 // `IsArray` abstract operation
559 // https://tc39.github.io/ecma262/#sec-isarray
560 var isArray = Array.isArray || function isArray(arg) {
561 return classofRaw(arg) == 'Array';
562 };
563
564 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
565 // Chrome 38 Symbol has incorrect toString conversion
566 // eslint-disable-next-line no-undef
567 return !String(Symbol());
568 });
569
570 var Symbol$1 = global_1.Symbol;
571 var store$1 = shared('wks');
572
573 var wellKnownSymbol = function (name) {
574 return store$1[name] || (store$1[name] = nativeSymbol && Symbol$1[name]
575 || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
576 };
577
578 var SPECIES = wellKnownSymbol('species');
579
580 // `ArraySpeciesCreate` abstract operation
581 // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
582 var arraySpeciesCreate = function (originalArray, length) {
583 var C;
584 if (isArray(originalArray)) {
585 C = originalArray.constructor;
586 // cross-realm fallback
587 if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
588 else if (isObject(C)) {
589 C = C[SPECIES];
590 if (C === null) C = undefined;
591 }
592 } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
593 };
594
595 var push = [].push;
596
597 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
598 var createMethod$1 = function (TYPE) {
599 var IS_MAP = TYPE == 1;
600 var IS_FILTER = TYPE == 2;
601 var IS_SOME = TYPE == 3;
602 var IS_EVERY = TYPE == 4;
603 var IS_FIND_INDEX = TYPE == 6;
604 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
605 return function ($this, callbackfn, that, specificCreate) {
606 var O = toObject($this);
607 var self = indexedObject(O);
608 var boundFunction = bindContext(callbackfn, that, 3);
609 var length = toLength(self.length);
610 var index = 0;
611 var create = specificCreate || arraySpeciesCreate;
612 var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
613 var value, result;
614 for (;length > index; index++) if (NO_HOLES || index in self) {
615 value = self[index];
616 result = boundFunction(value, index, O);
617 if (TYPE) {
618 if (IS_MAP) target[index] = result; // map
619 else if (result) switch (TYPE) {
620 case 3: return true; // some
621 case 5: return value; // find
622 case 6: return index; // findIndex
623 case 2: push.call(target, value); // filter
624 } else if (IS_EVERY) return false; // every
625 }
626 }
627 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
628 };
629 };
630
631 var arrayIteration = {
632 // `Array.prototype.forEach` method
633 // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
634 forEach: createMethod$1(0),
635 // `Array.prototype.map` method
636 // https://tc39.github.io/ecma262/#sec-array.prototype.map
637 map: createMethod$1(1),
638 // `Array.prototype.filter` method
639 // https://tc39.github.io/ecma262/#sec-array.prototype.filter
640 filter: createMethod$1(2),
641 // `Array.prototype.some` method
642 // https://tc39.github.io/ecma262/#sec-array.prototype.some
643 some: createMethod$1(3),
644 // `Array.prototype.every` method
645 // https://tc39.github.io/ecma262/#sec-array.prototype.every
646 every: createMethod$1(4),
647 // `Array.prototype.find` method
648 // https://tc39.github.io/ecma262/#sec-array.prototype.find
649 find: createMethod$1(5),
650 // `Array.prototype.findIndex` method
651 // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
652 findIndex: createMethod$1(6)
653 };
654
655 var SPECIES$1 = wellKnownSymbol('species');
656
657 var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
658 return !fails(function () {
659 var array = [];
660 var constructor = array.constructor = {};
661 constructor[SPECIES$1] = function () {
662 return { foo: 1 };
663 };
664 return array[METHOD_NAME](Boolean).foo !== 1;
665 });
666 };
667
668 var $filter = arrayIteration.filter;
669
670
671 // `Array.prototype.filter` method
672 // https://tc39.github.io/ecma262/#sec-array.prototype.filter
673 // with adding support of @@species
674 _export({ target: 'Array', proto: true, forced: !arrayMethodHasSpeciesSupport('filter') }, {
675 filter: function filter(callbackfn /* , thisArg */) {
676 return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
677 }
678 });
679
680 var sloppyArrayMethod = function (METHOD_NAME, argument) {
681 var method = [][METHOD_NAME];
682 return !method || !fails(function () {
683 // eslint-disable-next-line no-useless-call,no-throw-literal
684 method.call(null, argument || function () { throw 1; }, 1);
685 });
686 };
687
688 var $indexOf = arrayIncludes.indexOf;
689
690
691 var nativeIndexOf = [].indexOf;
692
693 var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
694 var SLOPPY_METHOD = sloppyArrayMethod('indexOf');
695
696 // `Array.prototype.indexOf` method
697 // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
698 _export({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || SLOPPY_METHOD }, {
699 indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
700 return NEGATIVE_ZERO
701 // convert -0 to +0
702 ? nativeIndexOf.apply(this, arguments) || 0
703 : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
704 }
705 });
706
707 var createProperty = function (object, key, value) {
708 var propertyKey = toPrimitive(key);
709 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
710 else object[propertyKey] = value;
711 };
712
713 var SPECIES$2 = wellKnownSymbol('species');
714 var nativeSlice = [].slice;
715 var max$1 = Math.max;
716
717 // `Array.prototype.slice` method
718 // https://tc39.github.io/ecma262/#sec-array.prototype.slice
719 // fallback for not array-like ES3 strings and DOM objects
720 _export({ target: 'Array', proto: true, forced: !arrayMethodHasSpeciesSupport('slice') }, {
721 slice: function slice(start, end) {
722 var O = toIndexedObject(this);
723 var length = toLength(O.length);
724 var k = toAbsoluteIndex(start, length);
725 var fin = toAbsoluteIndex(end === undefined ? length : end, length);
726 // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
727 var Constructor, result, n;
728 if (isArray(O)) {
729 Constructor = O.constructor;
730 // cross-realm fallback
731 if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
732 Constructor = undefined;
733 } else if (isObject(Constructor)) {
734 Constructor = Constructor[SPECIES$2];
735 if (Constructor === null) Constructor = undefined;
736 }
737 if (Constructor === Array || Constructor === undefined) {
738 return nativeSlice.call(O, k, fin);
739 }
740 }
741 result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0));
742 for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
743 result.length = n;
744 return result;
745 }
746 });
747
748 // a string of all valid unicode whitespaces
749 // eslint-disable-next-line max-len
750 var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
751
752 var whitespace = '[' + whitespaces + ']';
753 var ltrim = RegExp('^' + whitespace + whitespace + '*');
754 var rtrim = RegExp(whitespace + whitespace + '*$');
755
756 // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
757 var createMethod$2 = function (TYPE) {
758 return function ($this) {
759 var string = String(requireObjectCoercible($this));
760 if (TYPE & 1) string = string.replace(ltrim, '');
761 if (TYPE & 2) string = string.replace(rtrim, '');
762 return string;
763 };
764 };
765
766 var stringTrim = {
767 // `String.prototype.{ trimLeft, trimStart }` methods
768 // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
769 start: createMethod$2(1),
770 // `String.prototype.{ trimRight, trimEnd }` methods
771 // https://tc39.github.io/ecma262/#sec-string.prototype.trimend
772 end: createMethod$2(2),
773 // `String.prototype.trim` method
774 // https://tc39.github.io/ecma262/#sec-string.prototype.trim
775 trim: createMethod$2(3)
776 };
777
778 var trim = stringTrim.trim;
779
780
781 var nativeParseInt = global_1.parseInt;
782 var hex = /^[+-]?0[Xx]/;
783 var FORCED = nativeParseInt(whitespaces + '08') !== 8 || nativeParseInt(whitespaces + '0x16') !== 22;
784
785 // `parseInt` method
786 // https://tc39.github.io/ecma262/#sec-parseint-string-radix
787 var _parseInt = FORCED ? function parseInt(string, radix) {
788 var S = trim(String(string));
789 return nativeParseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10));
790 } : nativeParseInt;
791
792 // `parseInt` method
793 // https://tc39.github.io/ecma262/#sec-parseint-string-radix
794 _export({ global: true, forced: parseInt != _parseInt }, {
795 parseInt: _parseInt
796 });
797
798 /**
799 * @author doug-the-guy
800 * @version v1.0.0
801 *
802 * Bootstrap Table Pipeline
803 * -----------------------
804 *
805 * This plugin enables client side data caching for server side requests which will
806 * eliminate the need to issue a new request every page change. This will allow
807 * for a performance balance for a large data set between returning all data at once
808 * (client side paging) and a new server side request (server side paging).
809 *
810 * There are two new options:
811 * - usePipeline: enables this feature
812 * - pipelineSize: the size of each cache window
813 *
814 * The size of the pipeline must be evenly divisible by the current page size. This is
815 * assured by rounding up to the nearest evenly divisible value. For example, if
816 * the pipeline size is 4990 and the current page size is 25, then pipeline size will
817 * be dynamically set to 5000.
818 *
819 * The cache windows are computed based on the pipeline size and the total number of rows
820 * returned by the server side query. For example, with pipeline size 500 and total rows
821 * 1300, the cache windows will be:
822 *
823 * [{'lower': 0, 'upper': 499}, {'lower': 500, 'upper': 999}, {'lower': 1000, 'upper': 1499}]
824 *
825 * Using the limit (i.e. the pipelineSize) and offset parameters, the server side request
826 * **MUST** return only the data in the requested cache window **AND** the total number of rows.
827 * To wit, the server side code must use the offset and limit parameters to prepare the response
828 * data.
829 *
830 * On a page change, the new offset is checked if it is within the current cache window. If so,
831 * the requested page data is returned from the cached data set. Otherwise, a new server side
832 * request will be issued for the new cache window.
833 *
834 * The current cached data is only invalidated on these events:
835 * * sorting
836 * * searching
837 * * page size change
838 * * page change moves into a new cache window
839 *
840 * There are two new events:
841 * - cached-data-hit.bs.table: issued when cached data is used on a page change
842 * - cached-data-reset.bs.table: issued when the cached data is invalidated and a
843 * new server side request is issued
844 *
845 **/
846
847 var Utils = $.fn.bootstrapTable.utils;
848 $.extend($.fn.bootstrapTable.defaults, {
849 usePipeline: false,
850 pipelineSize: 1000,
851 onCachedDataHit: function onCachedDataHit(data) {
852 return false;
853 },
854 onCachedDataReset: function onCachedDataReset(data) {
855 return false;
856 }
857 });
858 $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
859 'cached-data-hit.bs.table': 'onCachedDataHit',
860 'cached-data-reset.bs.table': 'onCachedDataReset'
861 });
862 var BootstrapTable = $.fn.bootstrapTable.Constructor;
863 var _init = BootstrapTable.prototype.init;
864 var _initServer = BootstrapTable.prototype.initServer;
865 var _onSearch = BootstrapTable.prototype.onSearch;
866 var _onSort = BootstrapTable.prototype.onSort;
867 var _onPageListChange = BootstrapTable.prototype.onPageListChange;
868
869 BootstrapTable.prototype.init = function () {
870 // needs to be called before initServer()
871 this.initPipeline();
872
873 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
874 args[_key] = arguments[_key];
875 }
876
877 _init.apply(this, Array.prototype.slice.apply(args));
878 };
879
880 BootstrapTable.prototype.initPipeline = function () {
881 this.cacheRequestJSON = {};
882 this.cacheWindows = [];
883 this.currWindow = 0;
884 this.resetCache = true;
885 };
886
887 BootstrapTable.prototype.onSearch = function (event) {
888 /* force a cache reset on search */
889 if (this.options.usePipeline) {
890 this.resetCache = true;
891 }
892
893 _onSearch.apply(this, Array.prototype.slice.apply(arguments));
894 };
895
896 BootstrapTable.prototype.onSort = function (event) {
897 /* force a cache reset on sort */
898 if (this.options.usePipeline) {
899 this.resetCache = true;
900 }
901
902 _onSort.apply(this, Array.prototype.slice.apply(arguments));
903 };
904
905 BootstrapTable.prototype.onPageListChange = function (event) {
906 /* rebuild cache window on page size change */
907 var target = $(event.currentTarget);
908 var newPageSize = parseInt(target.text());
909 this.options.pipelineSize = this.calculatePipelineSize(this.options.pipelineSize, newPageSize);
910 this.resetCache = true;
911
912 _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
913 };
914
915 BootstrapTable.prototype.calculatePipelineSize = function (pipelineSize, pageSize) {
916 /* calculate pipeline size by rounding up to the nearest value evenly divisible
917 * by the pageSize */
918 if (pageSize === 0) return 0;
919 return Math.ceil(pipelineSize / pageSize) * pageSize;
920 };
921
922 BootstrapTable.prototype.setCacheWindows = function () {
923 /* set cache windows based on the total number of rows returned by server side
924 * request and the pipelineSize */
925 this.cacheWindows = [];
926 var numWindows = this.options.totalRows / this.options.pipelineSize;
927
928 for (var i = 0; i <= numWindows; i++) {
929 var b = i * this.options.pipelineSize;
930 this.cacheWindows[i] = {
931 'lower': b,
932 'upper': b + this.options.pipelineSize - 1
933 };
934 }
935 };
936
937 BootstrapTable.prototype.setCurrWindow = function (offset) {
938 /* set the current cache window index, based on where the current offset falls */
939 this.currWindow = 0;
940
941 for (var i = 0; i < this.cacheWindows.length; i++) {
942 if (this.cacheWindows[i].lower <= offset && offset <= this.cacheWindows[i].upper) {
943 this.currWindow = i;
944 break;
945 }
946 }
947 };
948
949 BootstrapTable.prototype.drawFromCache = function (offset, limit) {
950 /* draw rows from the cache using offset and limit */
951 var res = $.extend(true, {}, this.cacheRequestJSON);
952 var drawStart = offset - this.cacheWindows[this.currWindow].lower;
953 var drawEnd = drawStart + limit;
954 res.rows = res.rows.slice(drawStart, drawEnd);
955 return res;
956 };
957
958 BootstrapTable.prototype.initServer = function (silent, query, url) {
959 /* determine if requested data is in cache (on paging) or if
960 * a new ajax request needs to be issued (sorting, searching, paging
961 * moving outside of cached data, page size change)
962 * initial version of this extension will entirely override base initServer
963 **/
964 var data = {};
965 var index = this.header.fields.indexOf(this.options.sortName);
966 var params = {
967 searchText: this.searchText,
968 sortName: this.options.sortName,
969 sortOrder: this.options.sortOrder
970 };
971 var request = null;
972
973 if (this.header.sortNames[index]) {
974 params.sortName = this.header.sortNames[index];
975 }
976
977 if (this.options.pagination && this.options.sidePagination === 'server') {
978 params.pageSize = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
979 params.pageNumber = this.options.pageNumber;
980 }
981
982 if (!(url || this.options.url) && !this.options.ajax) {
983 return;
984 }
985
986 var useAjax = true;
987
988 if (this.options.queryParamsType === 'limit') {
989 params = {
990 searchText: params.searchText,
991 sortName: params.sortName,
992 sortOrder: params.sortOrder
993 };
994
995 if (this.options.pagination && this.options.sidePagination === 'server') {
996 params.limit = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
997 params.offset = (this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize) * (this.options.pageNumber - 1);
998
999 if (this.options.usePipeline) {
1000 // if cacheWindows is empty, this is the initial request
1001 if (!this.cacheWindows.length) {
1002 useAjax = true;
1003 params.drawOffset = params.offset; // cache exists: determine if the page request is entirely within the current cached window
1004 } else {
1005 var w = this.cacheWindows[this.currWindow]; // case 1: reset cache but stay within current window (e.g. column sort)
1006 // case 2: move outside of the current window (e.g. search or paging)
1007 // since each cache window is aligned with the current page size
1008 // checking if params.offset is outside the current window is sufficient.
1009 // need to requery for preceding or succeeding cache window
1010 // also handle case
1011
1012 if (this.resetCache || params.offset < w.lower || params.offset > w.upper) {
1013 useAjax = true;
1014 this.setCurrWindow(params.offset); // store the relative offset for drawing the page data afterwards
1015
1016 params.drawOffset = params.offset; // now set params.offset to the lower bound of the new cache window
1017 // the server will return that whole cache window
1018
1019 params.offset = this.cacheWindows[this.currWindow].lower; // within current cache window
1020 } else {
1021 useAjax = false;
1022 }
1023 }
1024 } else {
1025 if (params.limit === 0) {
1026 delete params.limit;
1027 }
1028 }
1029 }
1030 } // force an ajax call - this is on search, sort or page size change
1031
1032
1033 if (this.resetCache) {
1034 useAjax = true;
1035 this.resetCache = false;
1036 }
1037
1038 if (this.options.usePipeline && useAjax) {
1039 /* in this scenario limit is used on the server to get the cache window
1040 * and drawLimit is used to get the page data afterwards */
1041 params.drawLimit = params.limit;
1042 params.limit = this.options.pipelineSize;
1043 } // cached results can be used
1044
1045
1046 if (!useAjax) {
1047 var res = this.drawFromCache(params.offset, params.limit);
1048 this.load(res);
1049 this.trigger('load-success', res);
1050 this.trigger('cached-data-hit', res);
1051 return;
1052 } // cached results can't be used
1053 // continue base initServer code
1054
1055
1056 if (!$.isEmptyObject(this.filterColumnsPartial)) {
1057 params.filter = JSON.stringify(this.filterColumnsPartial, null);
1058 }
1059
1060 data = Utils.calculateObjectValue(this.options, this.options.queryParams, [params], data);
1061 $.extend(data, query || {}); // false to stop request
1062
1063 if (data === false) {
1064 return;
1065 }
1066
1067 if (!silent) {
1068 this.$tableLoading.show();
1069 }
1070
1071 var self = this;
1072 request = $.extend({}, Utils.calculateObjectValue(null, this.options.ajaxOptions), {
1073 type: this.options.method,
1074 url: url || this.options.url,
1075 data: this.options.contentType === 'application/json' && this.options.method === 'post' ? JSON.stringify(data) : data,
1076 cache: this.options.cache,
1077 contentType: this.options.contentType,
1078 dataType: this.options.dataType,
1079 success: function success(res) {
1080 res = Utils.calculateObjectValue(self.options, self.options.responseHandler, [res], res); // cache results if using pipelining
1081
1082 if (self.options.usePipeline) {
1083 // store entire request in cache
1084 self.cacheRequestJSON = $.extend(true, {}, res); // this gets set in load() also but needs to be set before
1085 // setting cacheWindows
1086
1087 self.options.totalRows = res[self.options.totalField]; // if this is a search, potentially less results will be returned
1088 // so cache windows need to be rebuilt. Otherwise it
1089 // will come out the same
1090
1091 self.setCacheWindows();
1092 self.setCurrWindow(params.drawOffset); // just load data for the page
1093
1094 res = self.drawFromCache(params.drawOffset, params.drawLimit);
1095 self.trigger('cached-data-reset', res);
1096 }
1097
1098 self.load(res);
1099 self.trigger('load-success', res);
1100 if (!silent) self.$tableLoading.hide();
1101 },
1102 error: function error(res) {
1103 var data = [];
1104
1105 if (self.options.sidePagination === 'server') {
1106 data = {};
1107 data[self.options.totalField] = 0;
1108 data[self.options.dataField] = [];
1109 }
1110
1111 self.load(data);
1112 self.trigger('load-error', res.status, res);
1113 if (!silent) self.$tableLoading.hide();
1114 }
1115 });
1116
1117 if (this.options.ajax) {
1118 Utils.calculateObjectValue(this, this.options.ajax, [request], null);
1119 } else {
1120 if (this._xhr && this._xhr.readyState !== 4) {
1121 this._xhr.abort();
1122 }
1123
1124 this._xhr = $.ajax(request);
1125 }
1126 };
1127
1128}));