bootstrap-table-group-by.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  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. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  7. var aFunction = function (it) {
  8. if (typeof it != 'function') {
  9. throw TypeError(String(it) + ' is not a function');
  10. } return it;
  11. };
  12. // optional / simple context binding
  13. var bindContext = function (fn, that, length) {
  14. aFunction(fn);
  15. if (that === undefined) return fn;
  16. switch (length) {
  17. case 0: return function () {
  18. return fn.call(that);
  19. };
  20. case 1: return function (a) {
  21. return fn.call(that, a);
  22. };
  23. case 2: return function (a, b) {
  24. return fn.call(that, a, b);
  25. };
  26. case 3: return function (a, b, c) {
  27. return fn.call(that, a, b, c);
  28. };
  29. }
  30. return function (/* ...args */) {
  31. return fn.apply(that, arguments);
  32. };
  33. };
  34. var fails = function (exec) {
  35. try {
  36. return !!exec();
  37. } catch (e) {
  38. return true;
  39. }
  40. };
  41. var toString = {}.toString;
  42. var classofRaw = function (it) {
  43. return toString.call(it).slice(8, -1);
  44. };
  45. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  46. var split = ''.split;
  47. var indexedObject = fails(function () {
  48. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  49. // eslint-disable-next-line no-prototype-builtins
  50. return !Object('z').propertyIsEnumerable(0);
  51. }) ? function (it) {
  52. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  53. } : Object;
  54. // `RequireObjectCoercible` abstract operation
  55. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  56. var requireObjectCoercible = function (it) {
  57. if (it == undefined) throw TypeError("Can't call method on " + it);
  58. return it;
  59. };
  60. // `ToObject` abstract operation
  61. // https://tc39.github.io/ecma262/#sec-toobject
  62. var toObject = function (argument) {
  63. return Object(requireObjectCoercible(argument));
  64. };
  65. var ceil = Math.ceil;
  66. var floor = Math.floor;
  67. // `ToInteger` abstract operation
  68. // https://tc39.github.io/ecma262/#sec-tointeger
  69. var toInteger = function (argument) {
  70. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  71. };
  72. var min = Math.min;
  73. // `ToLength` abstract operation
  74. // https://tc39.github.io/ecma262/#sec-tolength
  75. var toLength = function (argument) {
  76. return argument > 0 ? min(toInteger(argument), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  77. };
  78. var isObject = function (it) {
  79. return typeof it === 'object' ? it !== null : typeof it === 'function';
  80. };
  81. // `IsArray` abstract operation
  82. // https://tc39.github.io/ecma262/#sec-isarray
  83. var isArray = Array.isArray || function isArray(arg) {
  84. return classofRaw(arg) == 'Array';
  85. };
  86. function createCommonjsModule(fn, module) {
  87. return module = { exports: {} }, fn(module, module.exports), module.exports;
  88. }
  89. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  90. var global = typeof window == 'object' && window && window.Math == Math ? window
  91. : typeof self == 'object' && self && self.Math == Math ? self
  92. // eslint-disable-next-line no-new-func
  93. : Function('return this')();
  94. // Thank's IE8 for his funny defineProperty
  95. var descriptors = !fails(function () {
  96. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  97. });
  98. var document = global.document;
  99. // typeof document.createElement is 'object' in old IE
  100. var exist = isObject(document) && isObject(document.createElement);
  101. var documentCreateElement = function (it) {
  102. return exist ? document.createElement(it) : {};
  103. };
  104. // Thank's IE8 for his funny defineProperty
  105. var ie8DomDefine = !descriptors && !fails(function () {
  106. return Object.defineProperty(documentCreateElement('div'), 'a', {
  107. get: function () { return 7; }
  108. }).a != 7;
  109. });
  110. var anObject = function (it) {
  111. if (!isObject(it)) {
  112. throw TypeError(String(it) + ' is not an object');
  113. } return it;
  114. };
  115. // 7.1.1 ToPrimitive(input [, PreferredType])
  116. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  117. // and the second argument - flag - preferred type is a string
  118. var toPrimitive = function (it, S) {
  119. if (!isObject(it)) return it;
  120. var fn, val;
  121. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  122. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  123. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  124. throw TypeError("Can't convert object to primitive value");
  125. };
  126. var nativeDefineProperty = Object.defineProperty;
  127. var f = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  128. anObject(O);
  129. P = toPrimitive(P, true);
  130. anObject(Attributes);
  131. if (ie8DomDefine) try {
  132. return nativeDefineProperty(O, P, Attributes);
  133. } catch (e) { /* empty */ }
  134. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  135. if ('value' in Attributes) O[P] = Attributes.value;
  136. return O;
  137. };
  138. var objectDefineProperty = {
  139. f: f
  140. };
  141. var createPropertyDescriptor = function (bitmap, value) {
  142. return {
  143. enumerable: !(bitmap & 1),
  144. configurable: !(bitmap & 2),
  145. writable: !(bitmap & 4),
  146. value: value
  147. };
  148. };
  149. var hide = descriptors ? function (object, key, value) {
  150. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  151. } : function (object, key, value) {
  152. object[key] = value;
  153. return object;
  154. };
  155. var setGlobal = function (key, value) {
  156. try {
  157. hide(global, key, value);
  158. } catch (e) {
  159. global[key] = value;
  160. } return value;
  161. };
  162. var shared = createCommonjsModule(function (module) {
  163. var SHARED = '__core-js_shared__';
  164. var store = global[SHARED] || setGlobal(SHARED, {});
  165. (module.exports = function (key, value) {
  166. return store[key] || (store[key] = value !== undefined ? value : {});
  167. })('versions', []).push({
  168. version: '3.0.0',
  169. mode: 'global',
  170. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  171. });
  172. });
  173. var id = 0;
  174. var postfix = Math.random();
  175. var uid = function (key) {
  176. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + postfix).toString(36));
  177. };
  178. // Chrome 38 Symbol has incorrect toString conversion
  179. var nativeSymbol = !fails(function () {
  180. });
  181. var store = shared('wks');
  182. var Symbol = global.Symbol;
  183. var wellKnownSymbol = function (name) {
  184. return store[name] || (store[name] = nativeSymbol && Symbol[name]
  185. || (nativeSymbol ? Symbol : uid)('Symbol.' + name));
  186. };
  187. var SPECIES = wellKnownSymbol('species');
  188. // `ArraySpeciesCreate` abstract operation
  189. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  190. var arraySpeciesCreate = function (originalArray, length) {
  191. var C;
  192. if (isArray(originalArray)) {
  193. C = originalArray.constructor;
  194. // cross-realm fallback
  195. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  196. else if (isObject(C)) {
  197. C = C[SPECIES];
  198. if (C === null) C = undefined;
  199. }
  200. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  201. };
  202. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  203. // 0 -> Array#forEach
  204. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  205. // 1 -> Array#map
  206. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  207. // 2 -> Array#filter
  208. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  209. // 3 -> Array#some
  210. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  211. // 4 -> Array#every
  212. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  213. // 5 -> Array#find
  214. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  215. // 6 -> Array#findIndex
  216. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  217. var arrayMethods = function (TYPE, specificCreate) {
  218. var IS_MAP = TYPE == 1;
  219. var IS_FILTER = TYPE == 2;
  220. var IS_SOME = TYPE == 3;
  221. var IS_EVERY = TYPE == 4;
  222. var IS_FIND_INDEX = TYPE == 6;
  223. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  224. var create = specificCreate || arraySpeciesCreate;
  225. return function ($this, callbackfn, that) {
  226. var O = toObject($this);
  227. var self = indexedObject(O);
  228. var boundFunction = bindContext(callbackfn, that, 3);
  229. var length = toLength(self.length);
  230. var index = 0;
  231. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  232. var value, result;
  233. for (;length > index; index++) if (NO_HOLES || index in self) {
  234. value = self[index];
  235. result = boundFunction(value, index, O);
  236. if (TYPE) {
  237. if (IS_MAP) target[index] = result; // map
  238. else if (result) switch (TYPE) {
  239. case 3: return true; // some
  240. case 5: return value; // find
  241. case 6: return index; // findIndex
  242. case 2: target.push(value); // filter
  243. } else if (IS_EVERY) return false; // every
  244. }
  245. }
  246. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  247. };
  248. };
  249. var SPECIES$1 = wellKnownSymbol('species');
  250. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  251. return !fails(function () {
  252. var array = [];
  253. var constructor = array.constructor = {};
  254. constructor[SPECIES$1] = function () {
  255. return { foo: 1 };
  256. };
  257. return array[METHOD_NAME](Boolean).foo !== 1;
  258. });
  259. };
  260. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  261. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  262. // Nashorn ~ JDK8 bug
  263. var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  264. var f$1 = NASHORN_BUG ? function propertyIsEnumerable(V) {
  265. var descriptor = nativeGetOwnPropertyDescriptor(this, V);
  266. return !!descriptor && descriptor.enumerable;
  267. } : nativePropertyIsEnumerable;
  268. var objectPropertyIsEnumerable = {
  269. f: f$1
  270. };
  271. // toObject with fallback for non-array-like ES3 strings
  272. var toIndexedObject = function (it) {
  273. return indexedObject(requireObjectCoercible(it));
  274. };
  275. var hasOwnProperty = {}.hasOwnProperty;
  276. var has = function (it, key) {
  277. return hasOwnProperty.call(it, key);
  278. };
  279. var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  280. var f$2 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
  281. O = toIndexedObject(O);
  282. P = toPrimitive(P, true);
  283. if (ie8DomDefine) try {
  284. return nativeGetOwnPropertyDescriptor$1(O, P);
  285. } catch (e) { /* empty */ }
  286. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  287. };
  288. var objectGetOwnPropertyDescriptor = {
  289. f: f$2
  290. };
  291. var functionToString = shared('native-function-to-string', Function.toString);
  292. var WeakMap = global.WeakMap;
  293. var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(functionToString.call(WeakMap));
  294. var shared$1 = shared('keys');
  295. var sharedKey = function (key) {
  296. return shared$1[key] || (shared$1[key] = uid(key));
  297. };
  298. var hiddenKeys = {};
  299. var WeakMap$1 = global.WeakMap;
  300. var set, get, has$1;
  301. var enforce = function (it) {
  302. return has$1(it) ? get(it) : set(it, {});
  303. };
  304. var getterFor = function (TYPE) {
  305. return function (it) {
  306. var state;
  307. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  308. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  309. } return state;
  310. };
  311. };
  312. if (nativeWeakMap) {
  313. var store$1 = new WeakMap$1();
  314. var wmget = store$1.get;
  315. var wmhas = store$1.has;
  316. var wmset = store$1.set;
  317. set = function (it, metadata) {
  318. wmset.call(store$1, it, metadata);
  319. return metadata;
  320. };
  321. get = function (it) {
  322. return wmget.call(store$1, it) || {};
  323. };
  324. has$1 = function (it) {
  325. return wmhas.call(store$1, it);
  326. };
  327. } else {
  328. var STATE = sharedKey('state');
  329. hiddenKeys[STATE] = true;
  330. set = function (it, metadata) {
  331. hide(it, STATE, metadata);
  332. return metadata;
  333. };
  334. get = function (it) {
  335. return has(it, STATE) ? it[STATE] : {};
  336. };
  337. has$1 = function (it) {
  338. return has(it, STATE);
  339. };
  340. }
  341. var internalState = {
  342. set: set,
  343. get: get,
  344. has: has$1,
  345. enforce: enforce,
  346. getterFor: getterFor
  347. };
  348. var redefine = createCommonjsModule(function (module) {
  349. var getInternalState = internalState.get;
  350. var enforceInternalState = internalState.enforce;
  351. var TEMPLATE = String(functionToString).split('toString');
  352. shared('inspectSource', function (it) {
  353. return functionToString.call(it);
  354. });
  355. (module.exports = function (O, key, value, options) {
  356. var unsafe = options ? !!options.unsafe : false;
  357. var simple = options ? !!options.enumerable : false;
  358. var noTargetGet = options ? !!options.noTargetGet : false;
  359. if (typeof value == 'function') {
  360. if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
  361. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  362. }
  363. if (O === global) {
  364. if (simple) O[key] = value;
  365. else setGlobal(key, value);
  366. return;
  367. } else if (!unsafe) {
  368. delete O[key];
  369. } else if (!noTargetGet && O[key]) {
  370. simple = true;
  371. }
  372. if (simple) O[key] = value;
  373. else hide(O, key, value);
  374. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  375. })(Function.prototype, 'toString', function toString() {
  376. return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
  377. });
  378. });
  379. var max = Math.max;
  380. var min$1 = Math.min;
  381. // Helper for a popular repeating case of the spec:
  382. // Let integer be ? ToInteger(index).
  383. // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
  384. var toAbsoluteIndex = function (index, length) {
  385. var integer = toInteger(index);
  386. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  387. };
  388. // `Array.prototype.{ indexOf, includes }` methods implementation
  389. // false -> Array#indexOf
  390. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  391. // true -> Array#includes
  392. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  393. var arrayIncludes = function (IS_INCLUDES) {
  394. return function ($this, el, fromIndex) {
  395. var O = toIndexedObject($this);
  396. var length = toLength(O.length);
  397. var index = toAbsoluteIndex(fromIndex, length);
  398. var value;
  399. // Array#includes uses SameValueZero equality algorithm
  400. // eslint-disable-next-line no-self-compare
  401. if (IS_INCLUDES && el != el) while (length > index) {
  402. value = O[index++];
  403. // eslint-disable-next-line no-self-compare
  404. if (value != value) return true;
  405. // Array#indexOf ignores holes, Array#includes - not
  406. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  407. if (O[index] === el) return IS_INCLUDES || index || 0;
  408. } return !IS_INCLUDES && -1;
  409. };
  410. };
  411. var arrayIndexOf = arrayIncludes(false);
  412. var objectKeysInternal = function (object, names) {
  413. var O = toIndexedObject(object);
  414. var i = 0;
  415. var result = [];
  416. var key;
  417. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  418. // Don't enum bug & hidden keys
  419. while (names.length > i) if (has(O, key = names[i++])) {
  420. ~arrayIndexOf(result, key) || result.push(key);
  421. }
  422. return result;
  423. };
  424. // IE8- don't enum bug keys
  425. var enumBugKeys = [
  426. 'constructor',
  427. 'hasOwnProperty',
  428. 'isPrototypeOf',
  429. 'propertyIsEnumerable',
  430. 'toLocaleString',
  431. 'toString',
  432. 'valueOf'
  433. ];
  434. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  435. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  436. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  437. return objectKeysInternal(O, hiddenKeys$1);
  438. };
  439. var objectGetOwnPropertyNames = {
  440. f: f$3
  441. };
  442. var f$4 = Object.getOwnPropertySymbols;
  443. var objectGetOwnPropertySymbols = {
  444. f: f$4
  445. };
  446. var Reflect = global.Reflect;
  447. // all object keys, includes non-enumerable and symbols
  448. var ownKeys = Reflect && Reflect.ownKeys || function ownKeys(it) {
  449. var keys = objectGetOwnPropertyNames.f(anObject(it));
  450. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  451. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  452. };
  453. var copyConstructorProperties = function (target, source) {
  454. var keys = ownKeys(source);
  455. var defineProperty = objectDefineProperty.f;
  456. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  457. for (var i = 0; i < keys.length; i++) {
  458. var key = keys[i];
  459. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  460. }
  461. };
  462. var replacement = /#|\.prototype\./;
  463. var isForced = function (feature, detection) {
  464. var value = data[normalize(feature)];
  465. return value == POLYFILL ? true
  466. : value == NATIVE ? false
  467. : typeof detection == 'function' ? fails(detection)
  468. : !!detection;
  469. };
  470. var normalize = isForced.normalize = function (string) {
  471. return String(string).replace(replacement, '.').toLowerCase();
  472. };
  473. var data = isForced.data = {};
  474. var NATIVE = isForced.NATIVE = 'N';
  475. var POLYFILL = isForced.POLYFILL = 'P';
  476. var isForced_1 = isForced;
  477. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  478. /*
  479. options.target - name of the target object
  480. options.global - target is the global object
  481. options.stat - export as static methods of target
  482. options.proto - export as prototype methods of target
  483. options.real - real prototype method for the `pure` version
  484. options.forced - export even if the native feature is available
  485. options.bind - bind methods to the target, required for the `pure` version
  486. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  487. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  488. options.sham - add a flag to not completely full polyfills
  489. options.enumerable - export as enumerable property
  490. options.noTargetGet - prevent calling a getter on target
  491. */
  492. var _export = function (options, source) {
  493. var TARGET = options.target;
  494. var GLOBAL = options.global;
  495. var STATIC = options.stat;
  496. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  497. if (GLOBAL) {
  498. target = global;
  499. } else if (STATIC) {
  500. target = global[TARGET] || setGlobal(TARGET, {});
  501. } else {
  502. target = (global[TARGET] || {}).prototype;
  503. }
  504. if (target) for (key in source) {
  505. sourceProperty = source[key];
  506. if (options.noTargetGet) {
  507. descriptor = getOwnPropertyDescriptor(target, key);
  508. targetProperty = descriptor && descriptor.value;
  509. } else targetProperty = target[key];
  510. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  511. // contained in target
  512. if (!FORCED && targetProperty !== undefined) {
  513. if (typeof sourceProperty === typeof targetProperty) continue;
  514. copyConstructorProperties(sourceProperty, targetProperty);
  515. }
  516. // add a flag to not completely full polyfills
  517. if (options.sham || (targetProperty && targetProperty.sham)) {
  518. hide(sourceProperty, 'sham', true);
  519. }
  520. // extend global
  521. redefine(target, key, sourceProperty, options);
  522. }
  523. };
  524. var internalFilter = arrayMethods(2);
  525. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  526. // `Array.prototype.filter` method
  527. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  528. // with adding support of @@species
  529. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT }, {
  530. filter: function filter(callbackfn /* , thisArg */) {
  531. return internalFilter(this, callbackfn, arguments[1]);
  532. }
  533. });
  534. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  535. var objectKeys = Object.keys || function keys(O) {
  536. return objectKeysInternal(O, enumBugKeys);
  537. };
  538. var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  539. anObject(O);
  540. var keys = objectKeys(Properties);
  541. var length = keys.length;
  542. var i = 0;
  543. var key;
  544. while (length > i) objectDefineProperty.f(O, key = keys[i++], Properties[key]);
  545. return O;
  546. };
  547. var document$1 = global.document;
  548. var html = document$1 && document$1.documentElement;
  549. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  550. var IE_PROTO = sharedKey('IE_PROTO');
  551. var PROTOTYPE = 'prototype';
  552. var Empty = function () { /* empty */ };
  553. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  554. var createDict = function () {
  555. // Thrash, waste and sodomy: IE GC bug
  556. var iframe = documentCreateElement('iframe');
  557. var length = enumBugKeys.length;
  558. var lt = '<';
  559. var script = 'script';
  560. var gt = '>';
  561. var js = 'java' + script + ':';
  562. var iframeDocument;
  563. iframe.style.display = 'none';
  564. html.appendChild(iframe);
  565. iframe.src = String(js);
  566. iframeDocument = iframe.contentWindow.document;
  567. iframeDocument.open();
  568. iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
  569. iframeDocument.close();
  570. createDict = iframeDocument.F;
  571. while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
  572. return createDict();
  573. };
  574. var objectCreate = Object.create || function create(O, Properties) {
  575. var result;
  576. if (O !== null) {
  577. Empty[PROTOTYPE] = anObject(O);
  578. result = new Empty();
  579. Empty[PROTOTYPE] = null;
  580. // add "__proto__" for Object.getPrototypeOf polyfill
  581. result[IE_PROTO] = O;
  582. } else result = createDict();
  583. return Properties === undefined ? result : objectDefineProperties(result, Properties);
  584. };
  585. hiddenKeys[IE_PROTO] = true;
  586. var UNSCOPABLES = wellKnownSymbol('unscopables');
  587. var ArrayPrototype = Array.prototype;
  588. // Array.prototype[@@unscopables]
  589. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  590. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  591. hide(ArrayPrototype, UNSCOPABLES, objectCreate(null));
  592. }
  593. // add a key to Array.prototype[@@unscopables]
  594. var addToUnscopables = function (key) {
  595. ArrayPrototype[UNSCOPABLES][key] = true;
  596. };
  597. var internalFind = arrayMethods(5);
  598. var FIND = 'find';
  599. var SKIPS_HOLES = true;
  600. // Shouldn't skip holes
  601. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  602. // `Array.prototype.find` method
  603. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  604. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  605. find: function find(callbackfn /* , that = undefined */) {
  606. return internalFind(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  607. }
  608. });
  609. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  610. addToUnscopables(FIND);
  611. var sloppyArrayMethod = function (METHOD_NAME, argument) {
  612. var method = [][METHOD_NAME];
  613. return !method || !fails(function () {
  614. // eslint-disable-next-line no-useless-call
  615. method.call(null, argument || function () { throw Error(); }, 1);
  616. });
  617. };
  618. var nativeJoin = [].join;
  619. var ES3_STRINGS = indexedObject != Object;
  620. var SLOPPY_METHOD = sloppyArrayMethod('join', ',');
  621. // `Array.prototype.join` method
  622. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  623. _export({ target: 'Array', proto: true, forced: ES3_STRINGS || SLOPPY_METHOD }, {
  624. join: function join(separator) {
  625. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  626. }
  627. });
  628. var createProperty = function (object, key, value) {
  629. var propertyKey = toPrimitive(key);
  630. if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
  631. else object[propertyKey] = value;
  632. };
  633. var SPECIES$2 = wellKnownSymbol('species');
  634. var nativeSlice = [].slice;
  635. var max$1 = Math.max;
  636. var SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('slice');
  637. // `Array.prototype.slice` method
  638. // https://tc39.github.io/ecma262/#sec-array.prototype.slice
  639. // fallback for not array-like ES3 strings and DOM objects
  640. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$1 }, {
  641. slice: function slice(start, end) {
  642. var O = toIndexedObject(this);
  643. var length = toLength(O.length);
  644. var k = toAbsoluteIndex(start, length);
  645. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  646. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  647. var Constructor, result, n;
  648. if (isArray(O)) {
  649. Constructor = O.constructor;
  650. // cross-realm fallback
  651. if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
  652. Constructor = undefined;
  653. } else if (isObject(Constructor)) {
  654. Constructor = Constructor[SPECIES$2];
  655. if (Constructor === null) Constructor = undefined;
  656. }
  657. if (Constructor === Array || Constructor === undefined) {
  658. return nativeSlice.call(O, k, fin);
  659. }
  660. }
  661. result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0));
  662. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  663. result.length = n;
  664. return result;
  665. }
  666. });
  667. var nativeSort = [].sort;
  668. var test = [1, 2, 3];
  669. // IE8-
  670. var FAILS_ON_UNDEFINED = fails(function () {
  671. test.sort(undefined);
  672. });
  673. // V8 bug
  674. var FAILS_ON_NULL = fails(function () {
  675. test.sort(null);
  676. });
  677. // Old WebKit
  678. var SLOPPY_METHOD$1 = sloppyArrayMethod('sort');
  679. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || SLOPPY_METHOD$1;
  680. // `Array.prototype.sort` method
  681. // https://tc39.github.io/ecma262/#sec-array.prototype.sort
  682. _export({ target: 'Array', proto: true, forced: FORCED }, {
  683. sort: function sort(comparefn) {
  684. return comparefn === undefined
  685. ? nativeSort.call(toObject(this))
  686. : nativeSort.call(toObject(this), aFunction(comparefn));
  687. }
  688. });
  689. var defineProperty = objectDefineProperty.f;
  690. var FunctionPrototype = Function.prototype;
  691. var FunctionPrototypeToString = FunctionPrototype.toString;
  692. var nameRE = /^\s*function ([^ (]*)/;
  693. var NAME = 'name';
  694. // Function instances `.name` property
  695. // https://tc39.github.io/ecma262/#sec-function-instances-name
  696. if (descriptors && !(NAME in FunctionPrototype)) {
  697. defineProperty(FunctionPrototype, NAME, {
  698. configurable: true,
  699. get: function () {
  700. try {
  701. return FunctionPrototypeToString.call(this).match(nameRE)[1];
  702. } catch (e) {
  703. return '';
  704. }
  705. }
  706. });
  707. }
  708. // CONVERT_TO_STRING: true -> String#at
  709. // CONVERT_TO_STRING: false -> String#codePointAt
  710. var stringAt = function (that, pos, CONVERT_TO_STRING) {
  711. var S = String(requireObjectCoercible(that));
  712. var position = toInteger(pos);
  713. var size = S.length;
  714. var first, second;
  715. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  716. first = S.charCodeAt(position);
  717. return first < 0xd800 || first > 0xdbff || position + 1 === size
  718. || (second = S.charCodeAt(position + 1)) < 0xdc00 || second > 0xdfff
  719. ? CONVERT_TO_STRING ? S.charAt(position) : first
  720. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xd800 << 10) + (second - 0xdc00) + 0x10000;
  721. };
  722. // `AdvanceStringIndex` abstract operation
  723. // https://tc39.github.io/ecma262/#sec-advancestringindex
  724. var advanceStringIndex = function (S, index, unicode) {
  725. return index + (unicode ? stringAt(S, index, true).length : 1);
  726. };
  727. // `RegExp.prototype.flags` getter implementation
  728. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  729. var regexpFlags = function () {
  730. var that = anObject(this);
  731. var result = '';
  732. if (that.global) result += 'g';
  733. if (that.ignoreCase) result += 'i';
  734. if (that.multiline) result += 'm';
  735. if (that.unicode) result += 'u';
  736. if (that.sticky) result += 'y';
  737. return result;
  738. };
  739. var nativeExec = RegExp.prototype.exec;
  740. // This always refers to the native implementation, because the
  741. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  742. // which loads this file before patching the method.
  743. var nativeReplace = String.prototype.replace;
  744. var patchedExec = nativeExec;
  745. var UPDATES_LAST_INDEX_WRONG = (function () {
  746. var re1 = /a/;
  747. var re2 = /b*/g;
  748. nativeExec.call(re1, 'a');
  749. nativeExec.call(re2, 'a');
  750. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  751. })();
  752. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  753. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  754. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
  755. if (PATCH) {
  756. patchedExec = function exec(str) {
  757. var re = this;
  758. var lastIndex, reCopy, match, i;
  759. if (NPCG_INCLUDED) {
  760. reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
  761. }
  762. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  763. match = nativeExec.call(re, str);
  764. if (UPDATES_LAST_INDEX_WRONG && match) {
  765. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  766. }
  767. if (NPCG_INCLUDED && match && match.length > 1) {
  768. // Fix browsers whose `exec` methods don't consistently return `undefined`
  769. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  770. nativeReplace.call(match[0], reCopy, function () {
  771. for (i = 1; i < arguments.length - 2; i++) {
  772. if (arguments[i] === undefined) match[i] = undefined;
  773. }
  774. });
  775. }
  776. return match;
  777. };
  778. }
  779. var regexpExec = patchedExec;
  780. // `RegExpExec` abstract operation
  781. // https://tc39.github.io/ecma262/#sec-regexpexec
  782. var regexpExecAbstract = function (R, S) {
  783. var exec = R.exec;
  784. if (typeof exec === 'function') {
  785. var result = exec.call(R, S);
  786. if (typeof result !== 'object') {
  787. throw TypeError('RegExp exec method returned something other than an Object or null');
  788. }
  789. return result;
  790. }
  791. if (classofRaw(R) !== 'RegExp') {
  792. throw TypeError('RegExp#exec called on incompatible receiver');
  793. }
  794. return regexpExec.call(R, S);
  795. };
  796. var SPECIES$3 = wellKnownSymbol('species');
  797. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  798. // #replace needs built-in support for named groups.
  799. // #match works fine because it just return the exec results, even if it has
  800. // a "grops" property.
  801. var re = /./;
  802. re.exec = function () {
  803. var result = [];
  804. result.groups = { a: '7' };
  805. return result;
  806. };
  807. return ''.replace(re, '$<a>') !== '7';
  808. });
  809. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  810. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  811. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  812. var re = /(?:)/;
  813. var originalExec = re.exec;
  814. re.exec = function () { return originalExec.apply(this, arguments); };
  815. var result = 'ab'.split(re);
  816. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  817. });
  818. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  819. var SYMBOL = wellKnownSymbol(KEY);
  820. var DELEGATES_TO_SYMBOL = !fails(function () {
  821. // String methods call symbol-named RegEp methods
  822. var O = {};
  823. O[SYMBOL] = function () { return 7; };
  824. return ''[KEY](O) != 7;
  825. });
  826. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  827. // Symbol-named RegExp methods call .exec
  828. var execCalled = false;
  829. var re = /a/;
  830. re.exec = function () { execCalled = true; return null; };
  831. if (KEY === 'split') {
  832. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  833. // a new one. We need to return the patched regex when creating the new one.
  834. re.constructor = {};
  835. re.constructor[SPECIES$3] = function () { return re; };
  836. }
  837. re[SYMBOL]('');
  838. return !execCalled;
  839. });
  840. if (
  841. !DELEGATES_TO_SYMBOL ||
  842. !DELEGATES_TO_EXEC ||
  843. (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
  844. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  845. ) {
  846. var nativeRegExpMethod = /./[SYMBOL];
  847. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  848. if (regexp.exec === regexpExec) {
  849. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  850. // The native String method already delegates to @@method (this
  851. // polyfilled function), leasing to infinite recursion.
  852. // We avoid it by directly calling the native @@method method.
  853. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  854. }
  855. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  856. }
  857. return { done: false };
  858. });
  859. var stringMethod = methods[0];
  860. var regexMethod = methods[1];
  861. redefine(String.prototype, KEY, stringMethod);
  862. redefine(RegExp.prototype, SYMBOL, length == 2
  863. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  864. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  865. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  866. // 21.2.5.6 RegExp.prototype[@@match](string)
  867. // 21.2.5.9 RegExp.prototype[@@search](string)
  868. : function (string) { return regexMethod.call(string, this); }
  869. );
  870. if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
  871. }
  872. };
  873. var max$2 = Math.max;
  874. var min$2 = Math.min;
  875. var floor$1 = Math.floor;
  876. var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
  877. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
  878. var maybeToString = function (it) {
  879. return it === undefined ? it : String(it);
  880. };
  881. // @@replace logic
  882. fixRegexpWellKnownSymbolLogic(
  883. 'replace',
  884. 2,
  885. function (REPLACE, nativeReplace, maybeCallNative) {
  886. return [
  887. // `String.prototype.replace` method
  888. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  889. function replace(searchValue, replaceValue) {
  890. var O = requireObjectCoercible(this);
  891. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  892. return replacer !== undefined
  893. ? replacer.call(searchValue, O, replaceValue)
  894. : nativeReplace.call(String(O), searchValue, replaceValue);
  895. },
  896. // `RegExp.prototype[@@replace]` method
  897. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  898. function (regexp, replaceValue) {
  899. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  900. if (res.done) return res.value;
  901. var rx = anObject(regexp);
  902. var S = String(this);
  903. var functionalReplace = typeof replaceValue === 'function';
  904. if (!functionalReplace) replaceValue = String(replaceValue);
  905. var global = rx.global;
  906. if (global) {
  907. var fullUnicode = rx.unicode;
  908. rx.lastIndex = 0;
  909. }
  910. var results = [];
  911. while (true) {
  912. var result = regexpExecAbstract(rx, S);
  913. if (result === null) break;
  914. results.push(result);
  915. if (!global) break;
  916. var matchStr = String(result[0]);
  917. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  918. }
  919. var accumulatedResult = '';
  920. var nextSourcePosition = 0;
  921. for (var i = 0; i < results.length; i++) {
  922. result = results[i];
  923. var matched = String(result[0]);
  924. var position = max$2(min$2(toInteger(result.index), S.length), 0);
  925. var captures = [];
  926. // NOTE: This is equivalent to
  927. // captures = result.slice(1).map(maybeToString)
  928. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  929. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  930. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  931. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  932. var namedCaptures = result.groups;
  933. if (functionalReplace) {
  934. var replacerArgs = [matched].concat(captures, position, S);
  935. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  936. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  937. } else {
  938. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  939. }
  940. if (position >= nextSourcePosition) {
  941. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  942. nextSourcePosition = position + matched.length;
  943. }
  944. }
  945. return accumulatedResult + S.slice(nextSourcePosition);
  946. }
  947. ];
  948. // https://tc39.github.io/ecma262/#sec-getsubstitution
  949. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  950. var tailPos = position + matched.length;
  951. var m = captures.length;
  952. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  953. if (namedCaptures !== undefined) {
  954. namedCaptures = toObject(namedCaptures);
  955. symbols = SUBSTITUTION_SYMBOLS;
  956. }
  957. return nativeReplace.call(replacement, symbols, function (match, ch) {
  958. var capture;
  959. switch (ch.charAt(0)) {
  960. case '$': return '$';
  961. case '&': return matched;
  962. case '`': return str.slice(0, position);
  963. case "'": return str.slice(tailPos);
  964. case '<':
  965. capture = namedCaptures[ch.slice(1, -1)];
  966. break;
  967. default: // \d\d?
  968. var n = +ch;
  969. if (n === 0) return match;
  970. if (n > m) {
  971. var f = floor$1(n / 10);
  972. if (f === 0) return match;
  973. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  974. return match;
  975. }
  976. capture = captures[n - 1];
  977. }
  978. return capture === undefined ? '' : capture;
  979. });
  980. }
  981. }
  982. );
  983. // iterable DOM collections
  984. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  985. var domIterables = {
  986. CSSRuleList: 0,
  987. CSSStyleDeclaration: 0,
  988. CSSValueList: 0,
  989. ClientRectList: 0,
  990. DOMRectList: 0,
  991. DOMStringList: 0,
  992. DOMTokenList: 1,
  993. DataTransferItemList: 0,
  994. FileList: 0,
  995. HTMLAllCollection: 0,
  996. HTMLCollection: 0,
  997. HTMLFormElement: 0,
  998. HTMLSelectElement: 0,
  999. MediaList: 0,
  1000. MimeTypeArray: 0,
  1001. NamedNodeMap: 0,
  1002. NodeList: 1,
  1003. PaintRequestList: 0,
  1004. Plugin: 0,
  1005. PluginArray: 0,
  1006. SVGLengthList: 0,
  1007. SVGNumberList: 0,
  1008. SVGPathSegList: 0,
  1009. SVGPointList: 0,
  1010. SVGStringList: 0,
  1011. SVGTransformList: 0,
  1012. SourceBufferList: 0,
  1013. StyleSheetList: 0,
  1014. TextTrackCueList: 0,
  1015. TextTrackList: 0,
  1016. TouchList: 0
  1017. };
  1018. var nativeForEach = [].forEach;
  1019. var internalForEach = arrayMethods(0);
  1020. var SLOPPY_METHOD$2 = sloppyArrayMethod('forEach');
  1021. // `Array.prototype.forEach` method implementation
  1022. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  1023. var arrayForEach = SLOPPY_METHOD$2 ? function forEach(callbackfn /* , thisArg */) {
  1024. return internalForEach(this, callbackfn, arguments[1]);
  1025. } : nativeForEach;
  1026. for (var COLLECTION_NAME in domIterables) {
  1027. var Collection = global[COLLECTION_NAME];
  1028. var CollectionPrototype = Collection && Collection.prototype;
  1029. // some Chrome versions have non-configurable methods on DOMTokenList
  1030. if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
  1031. hide(CollectionPrototype, 'forEach', arrayForEach);
  1032. } catch (e) {
  1033. CollectionPrototype.forEach = arrayForEach;
  1034. }
  1035. }
  1036. /**
  1037. * @author: Yura Knoxville
  1038. * @version: v1.1.0
  1039. */
  1040. var initBodyCaller;
  1041. var tableGroups; // it only does '%s', and return '' when arguments are undefined
  1042. var sprintf = function sprintf(str) {
  1043. var args = arguments;
  1044. var flag = true;
  1045. var i = 1;
  1046. str = str.replace(/%s/g, function () {
  1047. var arg = args[i++];
  1048. if (typeof arg === 'undefined') {
  1049. flag = false;
  1050. return '';
  1051. }
  1052. return arg;
  1053. });
  1054. return flag ? str : '';
  1055. };
  1056. var groupBy = function groupBy(array, f) {
  1057. var groups = {};
  1058. array.forEach(function (o) {
  1059. var group = f(o);
  1060. groups[group] = groups[group] || [];
  1061. groups[group].push(o);
  1062. });
  1063. return groups;
  1064. };
  1065. $.extend($.fn.bootstrapTable.defaults, {
  1066. groupBy: false,
  1067. groupByField: '',
  1068. groupByFormatter: undefined
  1069. });
  1070. var BootstrapTable = $.fn.bootstrapTable.Constructor;
  1071. var _initSort = BootstrapTable.prototype.initSort;
  1072. var _initBody = BootstrapTable.prototype.initBody;
  1073. var _updateSelected = BootstrapTable.prototype.updateSelected;
  1074. BootstrapTable.prototype.initSort = function () {
  1075. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1076. args[_key] = arguments[_key];
  1077. }
  1078. _initSort.apply(this, Array.prototype.slice.apply(args));
  1079. var that = this;
  1080. tableGroups = [];
  1081. if (this.options.groupBy && this.options.groupByField !== '') {
  1082. if (this.options.sortName !== this.options.groupByField) {
  1083. this.data.sort(function (a, b) {
  1084. return a[that.options.groupByField].localeCompare(b[that.options.groupByField]);
  1085. });
  1086. }
  1087. var groups = groupBy(that.data, function (item) {
  1088. return [item[that.options.groupByField]];
  1089. });
  1090. var index = 0;
  1091. $.each(groups, function (key, value) {
  1092. tableGroups.push({
  1093. id: index,
  1094. name: key,
  1095. data: value
  1096. });
  1097. value.forEach(function (item) {
  1098. if (!item._data) {
  1099. item._data = {};
  1100. }
  1101. item._data['parent-index'] = index;
  1102. });
  1103. index++;
  1104. });
  1105. }
  1106. };
  1107. BootstrapTable.prototype.initBody = function () {
  1108. initBodyCaller = true;
  1109. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1110. args[_key2] = arguments[_key2];
  1111. }
  1112. _initBody.apply(this, Array.prototype.slice.apply(args));
  1113. if (this.options.groupBy && this.options.groupByField !== '') {
  1114. var that = this;
  1115. var checkBox = false;
  1116. var visibleColumns = 0;
  1117. this.columns.forEach(function (column) {
  1118. if (column.checkbox) {
  1119. checkBox = true;
  1120. } else {
  1121. if (column.visible) {
  1122. visibleColumns += 1;
  1123. }
  1124. }
  1125. });
  1126. if (this.options.detailView && !this.options.cardView) {
  1127. visibleColumns += 1;
  1128. }
  1129. tableGroups.forEach(function (item) {
  1130. var html = [];
  1131. html.push(sprintf('<tr class="info groupBy expanded" data-group-index="%s">', item.id));
  1132. if (that.options.detailView && !that.options.cardView) {
  1133. html.push('<td class="detail"></td>');
  1134. }
  1135. if (checkBox) {
  1136. html.push('<td class="bs-checkbox">', '<input name="btSelectGroup" type="checkbox" />', '</td>');
  1137. }
  1138. var formattedValue = item.name;
  1139. if (typeof that.options.groupByFormatter === 'function') {
  1140. formattedValue = that.options.groupByFormatter(item.name, item.id, item.data);
  1141. }
  1142. html.push('<td', sprintf(' colspan="%s"', visibleColumns), '>', formattedValue, '</td>');
  1143. html.push('</tr>');
  1144. that.$body.find("tr[data-parent-index=".concat(item.id, "]:first")).before($(html.join('')));
  1145. });
  1146. this.$selectGroup = [];
  1147. this.$body.find('[name="btSelectGroup"]').each(function () {
  1148. var self = $(this);
  1149. that.$selectGroup.push({
  1150. group: self,
  1151. item: that.$selectItem.filter(function () {
  1152. return $(this).closest('tr').data('parent-index') === self.closest('tr').data('group-index');
  1153. })
  1154. });
  1155. });
  1156. this.$container.off('click', '.groupBy').on('click', '.groupBy', function () {
  1157. $(this).toggleClass('expanded');
  1158. that.$body.find("tr[data-parent-index=".concat($(this).closest('tr').data('group-index'), "]")).toggleClass('hidden');
  1159. });
  1160. this.$container.off('click', '[name="btSelectGroup"]').on('click', '[name="btSelectGroup"]', function (event) {
  1161. event.stopImmediatePropagation();
  1162. var self = $(this);
  1163. var checked = self.prop('checked');
  1164. that[checked ? 'checkGroup' : 'uncheckGroup']($(this).closest('tr').data('group-index'));
  1165. });
  1166. }
  1167. initBodyCaller = false;
  1168. this.updateSelected();
  1169. };
  1170. BootstrapTable.prototype.updateSelected = function () {
  1171. if (!initBodyCaller) {
  1172. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1173. args[_key3] = arguments[_key3];
  1174. }
  1175. _updateSelected.apply(this, Array.prototype.slice.apply(args));
  1176. if (this.options.groupBy && this.options.groupByField !== '') {
  1177. this.$selectGroup.forEach(function (item) {
  1178. var checkGroup = item.item.filter(':enabled').length === item.item.filter(':enabled').filter(':checked').length;
  1179. item.group.prop('checked', checkGroup);
  1180. });
  1181. }
  1182. }
  1183. };
  1184. BootstrapTable.prototype.getGroupSelections = function (index) {
  1185. var that = this;
  1186. return this.data.filter(function (row) {
  1187. return row[that.header.stateField] && row._data['parent-index'] === index;
  1188. });
  1189. };
  1190. BootstrapTable.prototype.checkGroup = function (index) {
  1191. this.checkGroup_(index, true);
  1192. };
  1193. BootstrapTable.prototype.uncheckGroup = function (index) {
  1194. this.checkGroup_(index, false);
  1195. };
  1196. BootstrapTable.prototype.checkGroup_ = function (index, checked) {
  1197. var rows;
  1198. var filter = function filter() {
  1199. return $(this).closest('tr').data('parent-index') === index;
  1200. };
  1201. if (!checked) {
  1202. rows = this.getGroupSelections(index);
  1203. }
  1204. this.$selectItem.filter(filter).prop('checked', checked);
  1205. this.updateRows();
  1206. this.updateSelected();
  1207. if (checked) {
  1208. rows = this.getGroupSelections(index);
  1209. }
  1210. this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
  1211. };
  1212. }));